QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21338 | #2817. 鸽鸽的分割 | none_c# | AC ✓ | 0ms | 3548kb | C++20 | 961b | 2022-03-04 16:09:22 | 2022-05-08 02:54:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ull long long
const int maxn = 1e6 + 5;
static int op[maxn][3],a[maxn],vis[maxn];
inline char nc() { static char buf[1000000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++; }
inline void read(int &sum) { char ch = nc(); sum = 0; while (ch < '0') ch = nc(); while (ch >= '0') sum = (sum << 3) + (sum << 1) + (ch ^ 48), ch = nc(); }
__int128 dp[100];
int main()
{
dp[0]=1;dp[1]=1;dp[2]=2;;
for(int i=3;i<=64;i++)
{
dp[i]=dp[i-1];
for(int j=2;j<=i;j++)
{
// if(i==4)cout<<j<<" "<<(j-2)*(i-1-j)+1<<endl;
dp[i]+=(j-2)*(i-j)+1;
}
}
ull n;
while(cin>>n)
{
if(dp[n]<=1e18){
cout<<(ull)dp[n]<<endl;continue;}
ull res=dp[n];
vector<int>nums;
while(res)
{
nums.push_back(res%10);
res/=10;
}
for(int i=nums.size()-1;i>=0;i--)cout<<nums[i];cout<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
0 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 61 62 63 64
output:
1 1 2 4 8 16 31 57 99 163 256 5036 27841 92171 231526 489406 523686 559737 597619 637393
result:
ok 20 lines