ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1209. 1, 10, 100, 1000...

Test #3, си
Posted by pavel6520 16 Jan 2018 00:30
Не проходит Тест 3.
из темы http://acm.timus.ru/forum/thread.aspx?id=40287&upd=636486286708718852 взял условие, на компьютере все в порядке, отсылаю в тимус: Time limit exceeded

#include <stdio.h>
int mas[99999];
long int i, n;
unsigned long int a, cou = 0, s = 0;
int main()
{
scanf("%d", &n);
for (i = 0; i < n; i++){
scanf("%u", &a);
cou = 0; s = 1;
while(s < a){
cou++;
s = s + cou;
}
if (a == s){
mas[i] = 1;
} else {
mas[i] = 0;
}

}
for (i = 0; i < n; i++){
printf("%d ", mas[i]);
}
return 0;
}

Подскажите пожалуйста что не так.
Re: Test #3, си
Posted by Mr.Creative 12 Feb 2018 04:22
your mass[99999] must be 'long long'. Because Ki <= (1 << 31) - 1;
Re: Test #3, си
Posted by chev 28 Feb 2018 22:45
Study the consistent pattern in a given sequence (1101001000...) and use the quadratic equation. Luck!
Re: Test #3, си
Posted by Tugalov 22 Sep 2018 18:23
#include<bits/stdc++.h>
using namespace std;
bool one(long long n)
{
long long m;
m=(1ll*sqrt(1+8*n)-1)/2;
if (m*(m+1)==2*n) return 1;
else return 0;
}
int main()
{ long long n,a[65535];
cin>>n;
for (int i=0;i<n;i++)
{
cin>>a[i];
}
for (int i=0;i<n;i++)
{
if (one (a[i]-1)) cout<<1<<" ";
else cout<<0<<" ";

}}