As I was participating in today’s contest START100, my solution again got rejected due to incompletion of sub task, when again, correct outputs were there. I am not able to understand how to know the subtask in contest problems.
My solution: https://www.codechef.com/viewsolution/1020480416
When i debugged the code (as per a new feature):
It showed:
Solution Failed on following Input
1
4
Your Output
2 1.0 1.0
But isn’t the output correct here, as per the problem?
@jade764
plzz refer the following solution for better understanding for the logic.
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
cout<<1<<" "<<1<<" "<<n-2<<endl;
}
return 0;
}
@jade764
the correct solution for this is include
using namespace std;
int main() {
// your code goes here
int t; cin>>t;
while(t–){
int n; cin>>n;
cout << n-2 << 1 << " " << 1 << " " <<endl;
}
return 0;
}
Explanation:-
int T; cin >> T; : This line of code reads an integer Tfrom the standard input.T` represents the number of test cases.
while (T–)
{: This is a while loop that iterates for each test case. The T-- decrement operator decreases the value of T by 1 in each iteration, and the loop continues until T becomes zero.
int N; cin >> N; : Inside the loop, this line of code reads an integer Nfrom the standard input.N` represents the total number of chocolates for the current test case.
N - 2; : It calculates the number of chocolates by subtracting 2 from the total number of chocolates N . This is done to ensure that every it has at least one chocolate, as required by the problem statement.