hdu 5742 It's All In The Mind
来源:互联网 发布:里士满大学 知乎 编辑:程序博客网 时间:2024/05/16 10:50
#include<iostream>using namespace std;int gcb(int a,int b){ int c; while(b) { c=b; b=a%b; a=c; } return a;}int main(){ int T; cin>>T; while(T--) { int n,m,i,x,y; cin>>n>>m; int a[105]; if(m==0) cout<<"1/1"<<endl; else { for(i=1; i<=n; i++) a[i]=-1; for(i=0; i<m; i++) { cin>>x>>y; a[x]=y; } int fenzi=0,sum=0; if(a[1]==-1) a[1]=100; if(a[2]==-1) a[2]=a[1]; for(i=n; i>=3; i--) { if(i==n) { if(a[i]==-1) a[i]=0; } else { if(a[i]==-1) a[i]=a[i+1]; //使分母尽量小,但这个数列是非递增的,所以a[i]最小只能跟a[i+1]相等 } sum+=a[i]; } fenzi=a[1]+a[2]; int x; x=gcb(fenzi,fenzi+sum); cout<<fenzi/x<<"/"<<(fenzi+sum)/x<<endl; } } return 0;}
0 0
- It's All In The Mind HDU
- 贪心-HDU-5742-It's All In The Mind
- HDU 5742 It's All In The Mind(贪心?)
- hdu 5742 It's All In The Mind
- HDU 5742 It's All In The Mind (水题)
- hdu 5742 It's All In The Mind
- 【HDU】5742 It's All In The Mind
- hdu 5742 It's All In The Mind
- HDU 5742 It's All In The Mind
- HDU 5742 It's All In The Mind(贪心)
- HDU 5742 It's All In The Mind 水题
- HDU 5742 It's All In The Mind 贪心
- 5742 ( It's All In The Mind )
- 2016HDU多校联赛-HDU-5742-It's All In The Mind
- It's All In The Mind
- hdu5742 It's All In The Mind
- HDU5742 It's All In The Mind
- hdu5742 It's All In The Mind
- POI使用:用poi接口不区分xls/xlsx格式解析Excel文档(41种日期格式解析方法,5种公式结果类型解析方法,3种常用数值类型精度控制办法)
- spark & 文件压缩
- 欢迎使用CSDN-markdown编辑器
- mPopupWindow.setOutsideTouchable(true)不生效问题
- GET和POST有什么区别?及为什么网上多数答案都是错的
- hdu 5742 It's All In The Mind
- Android中application取值为空
- 关于gamma调整和添加噪声测试
- CABAC 语法解析
- Java 中的类锁和对象锁
- GCC简明教程(4)
- 图片处理Java工具类(缩放,圆角,倒影)(未测试)
- POJ 1032 最大乘积
- select中option加事件问题