Mai intai trebuie sa te autentifici.
Cod sursa(job #1709056)
Utilizator | Data | 28 mai 2016 10:44:38 | |
---|---|---|---|
Problema | Consecutive | Scor | 0 |
Compilator | cpp | Status | done |
Runda | ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest | Marime | 0.79 kb |
#include <fstream>
using namespace std;
int v[10000];
int main()
{
int t,i,n,j,k,c,q;
long long s;
ifstream in("consecutive.in");
ofstream out("consecutive.out");
in>>t;
s=0;
c=0;
q=1;
for(i=1;i<=t;i++)
{
in>>n;
for(j=1;j<=n;j++)
{
s=0;
for(k=j;k<=n/2+1;k++)
{
s=s+k;
if(s==n)
{
v[q]=j;
v[q+1]=k;
q=q+2;
c++;
s=0;
break;
}
}
}
out<<c<<endl;
for(j=1;j<=q-2;j=j+2)
{
out<<v[j]<<" "<<v[j+1]<<endl;
}
}
return 0;
}