Codeforces Round #592 (Div. 2)

A

#include 
#include 
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int a,b,c,d,k;
        cin>>a>>b>>c>>d>>k;
        int x=a/c;
        int y=b/d;
        if(a%c!=0)x++;
        if(b%d!=0)y++;
        if(x+y>k){
            printf("-1\n");
        }else{
            printf("%d %d\n",x,y);
        }
    }
    return 0;
}

/*


a lectures and b practical classes 
 write down c lectures using one pen, 
 one pencil is enough to draw all blueprints during d practical classes, 

a=7 c=4
b=5 d=5
k=8


*/

B

#include 
#include 
#include 
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        string  s;
        cin>>n>>s;
        int ans = n;//默认为n,如果全部都是0的话,只能走n个


        for(int i=0;i

C(重点)

#include 
#include 
#define ll long long
using namespace std;
const int N=10*1000*1000;
int main(){
    ll n,p,w,d;//比赛的场数,最后得分,赢了的得分,平局的得分
    cin>>n>>p>>w>>d;

    for(ll i=0;i<=N;i++){//遍历一次x
        ll t = p-(w*i);//t = y*d
        if(t>=0&&t%d==0 && i+(t/d)<=n){//z的大小不用管,因为z的多少只与x和y的多少有关,而且z的多少不会对总分数产生影响
            cout<=0&&t%w==0 && i+(t/w)<=n){
            cout<

你可能感兴趣的:(Codeforces Round #592 (Div. 2))