1087 1 10) 100 1000

Source: Internet
Author: User

1087 1 10) 100 1000

Base time limit: 1 second space limit: 131072 kb1,10,100,1000 ... make sequence 1101001000 ... to find the nth bit of this sequence is 0 or 1. Input
Line 1th: A number t that represents the number of numbers that are later used as input tests. (1 <= T <= 10000) 2-t + 1 lines: 1 number n per line. (1 <= N <= 10^9)
Output
A total of T-lines, if the bit is 0, output 0, if the bit is 1, Output 1.
Input example
3123
Output example
110
#include <cstdio>#include<cmath>intMain () {intT scanf"%d", &t);  while(t--)    {        intN; scanf ("%d", &N); N-=1; if(n==0) {printf ("1\n"); Continue; } N*=2; intb=Floor (sqrt (n)); if(b* (b +1)==N) {printf ("1\n"); Continue; } printf ("0\n"); }    return 0;}

1087 1 10) 100 1000

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.