社区讨论
谁来帮一下这位蒟蒻,今晚CF B
学术版参与者 7已保存回复 11
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 11 条
- 当前快照
- 1 份
- 快照标识符
- @lo3gqqiq
- 此快照首次捕获于
- 2023/10/24 06:22 2 年前
- 此快照最后确认于
- 2023/10/24 06:22 2 年前
B画了图很快就推出式子了,但是写的时候发现最后一个溢出了,就用了__int128,用了__int128洛谷ide可过,我之前用的dev也可过,但最新的dev编辑不了,一直报错,就一个__int128废了我1个多小时,我选择了我之前用的dev的文件教了一发,CE了,后来有用新的dev交,又CE了,CE了n次,代码:
C#include<bits/stdc++.h>
using namespace std;
// ```
#define clog cout
#define plog printf
#define jd static
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define M make_pair
#define x first
#define y second
#define E emplace
#define EB emplace_back
#define EF emplace_front
#define p putchar
// 小写p
#define re register
#define P printf(" ");
// 大写P
#define endl puts("")
#define Yes puts("Yes")
#define No puts("No")
#define YES puts("YES")
#define NO puts("NO")
#define error puts("error")
#define IMPOSSIBLE puts("IMPOSSIBLE")
#define Impossible puts("Impossible")
#define fuyi puts("-1")
#define ll long long
#define ull unsigned long long
// ```
// ```函数
inline int gcd(int a,int b){
if(b) while((a%=b) && (b%=a));
return a+b;
}
/*inline int read(){
re int x=0,f=1;re char ch=getchar();
while(!isdigit(ch)){if(ch=='-') f=~f+1;ch=getchar();}
while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
inline ll read_ll(){
re ll x=0,f=1;re char ch=getchar();
while(!isdigit(ch)){if(ch=='-') f=~f+1;ch=getchar();}
while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
inline ull read_ull(){
re ull x=0,f=1;re char ch=getchar();
while(!isdigit(ch)){if(ch=='-') f=~f+1;ch=getchar();}
while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
inline unsigned int read_u(){
re unsigned int x=0,f=1;re char ch=getchar();
while(!isdigit(ch)){if(ch=='-') f=~f+1;ch=getchar();}
while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
*/
inline __int128 read(){
__int128 ret=0,f=1;
char ch=getchar();
while(ch<'0' || ch>'9'){
if(ch=='-')
f=-f;
ch=getchar();
}
while(ch>='0' && ch<='9')
ret=ret*10+ch-'0',ch=getchar();
return ret*f;
}
inline void print(__int128 x){
if(x<0){
putchar('-');
x=-x;
}
if(x>9) print(x/10);
putchar(x%10+'0');
}
// ```
const int MOD=1e9+7;
inline void solve(){
__int128 n=read(),i;
// 1 3 7 13 22 34 50
// 1*1+1*2+2*2+2*3+3*3+3*4+4*4+4*5
// 1*1+2*2+3*3 + 1*2+2*3 8 2*2+3*3 13
// 1*1+2*2+3*3+4*4 + 1*2+2*3+3*4 20 2*2+3*3+4*4 29
// n(n+1)(2n+1)/6 n*n-n
// 1000000000*1000000001*2000000001/6
// 5+4-1-1
// n*(n-1)/2
// n(n+1)(2n+1)/6+n(n+1)(2n+1)/6-1-(2+n)*(n-1)/2
// 28-1-5=22
__int128 cnt=n*(n+1)*(2*n+1)/6;
cnt*=2;
cnt--;
cnt-=(2+n)*(n-1)/2;
cnt*=2022;
print(cnt%MOD),endl;
return ;
}
int main(){
__int128 t=read();
while(t--) solve();
return 0;
}
回复
共 11 条回复,欢迎继续交流。
正在加载回复...