1 solutions
-
0
C++ :
#include <stdio.h> int main(int argc, char **argv) { long long a=0, b=0, m=0, n=0, ans=0, c=0, i; scanf("%lld%lld%lld%lld", &a, &b, &m, &n); ans = a+b; for(i=3; i<=n; i++) { c = a+b; ans += c; a = b; b = c; if(c>=m) break; } printf("%lld\n", ans); return 0; }
- 1
Information
- ID
- 38
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 9
- Tags
- # Submissions
- 7
- Accepted
- 7
- Uploaded By