1.Timus 1209 求序列的第N位是0还是1: 1, 10, 100, 1000...组成序列1101001000...,求这个序列的第n位是0还是1

/* */
#include<iostream>
#include<cmath>

using namespace std;


void is_zero(int n){
    int m = (sqrt(8*n+1)-1)/2;
    int re = n - m*(m+1)/2;
    if(n == 1||re == 1){
        cout<<"位置"<<n<<"该位置是1"<<endl;
    }
    else{
        cout<<"位置"<<n<<"该位置是0"<<endl;
    }
}


int main(){
    for(int i = 1;i<100;++i){
        is_zero(i);
    }
    return 0;
}

原文地址:https://www.cnblogs.com/candycloud/p/3332720.html