C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了C. The Football Season (枚举) ( Codeforces Round #592 (Div. 2) )大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

The football season has just ended in Berland. According to the rules of Berland football,each match is played between two teams. The result of each match is either a draw,or a victory of one of the playing teams. If a team wins the match,it gets ww points,and the opposing team gets 00 points. If the game results in a draw,both teams get dd points.

The manager of the Berland capital team wants to summarize the results of the season,but,unfortunately,all information about the results of each match is lost. The manager only kNows that the team has played nn games and got @H_419_70@pp points for them.

You have to determine three integers xx, yy and zz — the number of wins,draws and loses of the team. If there are multiple answers,print any of them. If there is no suitable triple (x,y,z)(x,y,z),report about it.

Input

The first line contains four integers nn, pp, ww and d(1n1012,0p1017,1d<w10@H_502_232@5)(1≤n≤1012,0≤p≤1017,1≤d<w≤105) — the number of games,the number of points the team got,the number of points awarded for winning a match,and the number of points awarded for a draw,respectively. Note that w>dw>d,so the number of points awarded for winning is strictly greater than the number of points awarded for draw.

Output

If there is no answer,print 1−1.

Otherwise print three non-negative integers xx, yy and zz — the number of wins,draws and losses of the team. If there are multiple possible triples (x,y,z)(x,print any of them. The numbers should meet the following conditions:

  • @H_191_403@@H_48_404@xw+yd=px⋅w+y⋅d=p,
  • x+y+z=nx+y+z=n.
Examples
input
Copy
30 60 3 1 
output
Copy
17 9 4 
input
Copy
10 51 5 4 
output
Copy
-1 
input
Copy
20 0 15 5 
output
Copy
0 0 20 
Note

One of the possible answers in the first example — 1717 wins, 99 draws and 44 losses. Then the team got 173+91=6017⋅3+9⋅1=60 points in 17+9+4=3017+9+4=30 games.

In the second example the maximum possible score is 105=5010⋅5=50. Since p=51p=51,there is no answer.

In the third example the team got 00 points,so all 2020 games were lost.

 

 

 

#include <bits/stdc++.h> using namespace std; #define ll long long #define TLE ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll m,n,l,r; int main() { TLE; while(cin>>n>>m>>l>>r) { for(int i=0;i<min(n,l);i++) { if(m-i*r<0) break; if( !((m-i*r)%l) ) { if(i+((m-i*r)/l) <=n ) { cout<<(m-i*r)/l<<" "<<i<<" "<<n-i-(m-i*r)/l<<endl; return 0; } } } cout<<-1<<endl; } return 0; }

大佬总结

以上是大佬教程为你收集整理的C. The Football Season (枚举) ( Codeforces Round #592 (Div. 2) )全部内容,希望文章能够帮你解决C. The Football Season (枚举) ( Codeforces Round #592 (Div. 2) )所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: