#include
using namespace std;
int main ()
{
int T = 0;
cin >> T;
int x=0;
int N [T];
int A [T];
int K [T];
int O [T];
for(x=1;x<=T;x++)
{
cin >> N[x] >> A[x] >> K[x];
}
for(x=1;x<=T;x++)
{
O[x] =A[x]+(K[x]-1)((360/N[x])(N[x]-2)-2*A[x])/(N[x]-1);
cout << O[x] <<" " << 1<<endl;
}
return 0;
}
Below is your formatted code:
#include<iostream>
using namespace std;
int main()
{
int T = 0;
cin >> T;
int x = 0;
int N[T];
int A[T];
int K[T];
int O[T];
for (x = 1; x <= T; x++)
{
cin >> N[x] >> A[x] >> K[x];
}
for (x = 1; x <= T; x++)
{
O[x] = A[x] + (K[x] - 1)((360 / N[x])(N[x] - 2) - 2 * A[x]) / (N[x] - 1);
cout << O[x] << " " << 1 << endl;
}
return 0;
}
Two major problems that I found by skimming through the code:
- Start loops from [0,T) or increase all array ranges to T+1.
-
cout << O[x] << " " << 1 << endl;
You are printing 1 in all of the cases. You are supposed to find the proper fraction and print it. Please see the editorial for more details.