c++ - Logic Error or Code error. Help me out -
a team gets 3 points win , 1 tie , 0 lose. have been given number of points scored team , number of matches played team. have find number of ways of win tie , lose.the follow code per me showing wrong answer , timeout error. please help
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { long long int t; cin>>t; (long long int k=0;k<t;k++) { long long int g,p; cin >> g >> p; long long int way=0; long long int w; w=p/3; (long long int i=w;i>=0;i--) { if ((p-3*i)<=(g-i)) { way=way+1; } else { break; } } cout << way << endl; } return 0; }
Comments
Post a Comment