日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

1430. Crime and Punishment

發布時間:2023/12/16 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1430. Crime and Punishment 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

http://acm.timus.ru/problem.aspx?space=1&num=1430

先讓 a 變成較大的那個

1,a 的個數 不會超過 n/a

2,a 的個數也可以不超過 b ,如果超過 b個a 可以由 a個b 代替 從而減輕了 a 的個數過大的負擔

然后枚舉 a 的個數

因為 a 變成較大的那個 所以? min(n/a,b)? 比較小

代碼:

#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<string> #include<vector> #include<map> #include<queue> #include<stack> #include<cmath> #define LL long long //#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std;const int INF=0x3f3f3f3f;int main() {//freopen("data.txt","r",stdin);LL a,b,n;while(cin>>a>>b>>n){bool change=false;if(a<b){change=true;swap(a,b);}LL k1,k2,MAX=-1;for(LL i=0;i<=min(n/a,b);++i){LL j=(n-i*a)/b;if(i*a+j*b>MAX){MAX=i*a+j*b;k1=i;k2=j;}}if(change)swap(k1,k2);cout<<k1<<" "<<k2<<endl;}return 0; }

?

轉載于:https://www.cnblogs.com/liulangye/archive/2012/10/25/2740072.html

總結

以上是生活随笔為你收集整理的1430. Crime and Punishment的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。