Infinite Sequence
below given code is for ins14i spoj or infinite sequence spoj.
if you want proof of solution please mail me @ raj.nishant360@gmail.com.
#include <bits/stdc++.h> using namespace std; #define X (3+2*sqrt(2)) int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); if(n==0){ printf("4\n");continue;} double temp,k; temp= ceil(n/X); k=floor(temp*X); if(k==n) printf("4\n"); else printf("5\n"); } return 0; }
No comments:
Post a Comment
Your comment is valuable to us