[2016-05-11][51nod][1087 1 10 100 1000]
时间:2016-05-11 14:03:56 星期三
题目编号:[2016-05-11][51nod][1087 1 10 100 1000]
题目大意:1,10,100,1000…组成序列1101001000…,求这个序列的第N位是0还是1。
分析:第的时候,n位置的数字为1
#include<stdio.h>#include<math.h>using namespace std;int main(){int t;scanf("%d",&t);while(t--){int n;scanf("%d",&n);int k = sqrt(double((n - 1) * 2 + 1.0 / 4)) - 0.5;if(k * (k + 1) == (n - 1) * 2){puts("1");}else puts("0");}return 0;}
浙公网安备 33010602011771号