|
|
back to boardplease help whats test12? whats my cod problem? //in the name of allah #include<stdio.h> int main() { int x=2, y=2, z; int i,n; scanf("%d\n", &n); if (n == 1 || n == 2) { printf("%d\n", 2); return 0; } for (i = 3; i<= n; i++){ z = x + y; x = y; y = z; } printf("%d\n", z); return 0; }
Re: please help Posted by luka 27 Jan 2017 17:57 #include<iostream> using namespace std; int n, m; int main() { cin>>n cout<<n+1; return 0; } try this Re: please help Note: luka didn't receive AC. Solution looks ... weird. Re: please help 1. It's better to help if author shows error (WA/TLE/etc) and test number. 2. int isn't enough. Try to use 64-bit variables. Re: please help the problem is that when the input number comes to 45, even data type long long int cannot hold as big a result as 2269806340;(the result for 45), not to mention type int. Re: please help long long is enough, 2269806340 is about 2^31-32, long long is 2^64, so it is double in the number of digits |
|
|