|
|
вернуться в форумIs there any difference between long long and __int64? My first code: #include <stdio.h> int n; long long f[501][501], g[501][501], res; void xxx(void) { for (int i=0; i<=n; i++) f[0][i] = 1; for (int i=1; i<35 && i<=n; i++) { for (int j=0; j<=n; j++) for (int k=0; k<=n; k++) { g[j][k] = f[j][k]; f[j][k] = 0; } for (int j=1; j<=n; j++) { for (int k=1; k<=j; k++) f[j][k] = f[j][k - 1] + g[j - k][k - 1]; for (int k=j+1; k<=n; k++) f[j][k] = f[j][j]; } res += f[n][n]; } } int main(void) { scanf("%d", &n); xxx(); printf("%lld\n", --res); return 0; } WA for #6. My second code: #include <stdio.h> int n; __int64 f[501][501], g[501][501], res; void xxx(void) { for (int i=0; i<=n; i++) f[0][i] = 1; for (int i=1; i<35 && i<=n; i++) { for (int j=0; j<=n; j++) for (int k=0; k<=n; k++) { g[j][k] = f[j][k]; f[j][k] = 0; } for (int j=1; j<=n; j++) { for (int k=1; k<=j; k++) f[j][k] = f[j][k - 1] + g[j - k][k - 1]; for (int k=j+1; k<=n; k++) f[j][k] = f[j][j]; } res += f[n][n]; } } int main(void) { scanf("%d", &n); xxx(); printf("%I64d\n", --res); return 0; } AC. Re: Is there any difference between long long and __int64? Edited by author 30.08.2010 08:37 Re: Is there any difference between long long and __int64? Difference only here: printf("%lld\n", --res); printf("%I64d\n", --res); #include <stdio.h> int n; long long f[501][501], g[501][501], res; void xxx(void) { for (int i=0; i<=n; i++) f[0][i] = 1; for (int i=1; i<35 && i<=n; i++) { for (int j=0; j<=n; j++) for (int k=0; k<=n; k++) { g[j][k] = f[j][k]; f[j][k] = 0; } for (int j=1; j<=n; j++) { for (int k=1; k<=j; k++) f[j][k] = f[j][k - 1] + g[j - k][k - 1]; for (int k=j+1; k<=n; k++) f[j][k] = f[j][j]; } res += f[n][n]; } } int main(void) { scanf("%d", &n); xxx(); printf("%I64d\n", --res); return 0; } This is AC. |
|
|