POJ3902 The Bad Number
来源:互联网 发布:网络用语什么叫狗粮 编辑:程序博客网 时间:2024/05/29 09:31
题意思路这里都写的很清楚→ →http://hi.baidu.com/chenwenwen0210/item/b4f142d53129fdc954347f11
我觉得这题真是太厉害了 作为一个程序员 严谨 认真 记忆力好 实在是太重要了 比起算法 不粗心大意显然更重要啊!
而这一题极大的考验了我们的耐心 细心。。bug王真心给跪了。。。
#include<iostream>#include<cstdio>#include<vector>#include<algorithm>#include<cstring>using namespace std;int main(){ int tmp,k,m,n,ans,t,res,tmpres; scanf("%d",&t); while(t--) { ans=0; scanf("%d%d%d",&n,&m,&k); if(n==1) { printf("-1\n"); continue; } if(k==1) { if(m%n==0) printf("-1\n"); else printf("%d\n",m); continue; } if(n==2) { if(m%n==0) printf("-1\n"); else { if(k%2==0) k--; ans=m/k; res=m%k; if(res>0) { ans++; if(res%2==0)ans++; } printf("%d\n",ans); } continue; } if(k%n==0) k--; res=m%k; ans+=m/k; if(res==0) { if(ans%n==0) ans++; printf("%d\n",ans); continue; } else//res>0 { ans++; if(ans%n==0) ans++; else { if(res%n==0) { if(ans==1) ans++; else if((k-1)%n==0) { bool flag=false; for(int i=1;i<n&&i+res<=k&&i<k;i++) { if((res+i)%n!=0&&(k-i)%n!=0) { flag=true; break; } } if(!flag) { ans++; if(ans%n==0) ans++; } } } } printf("%d\n",ans); } } return 0;}
- POJ3902 The Bad Number
- The Bad Number poj3902
- POJ 3902 The Bad Number(贪心)
- POJ 3902 The Bad Number第一次积分赛K题
- POJ 3902 The Bad Number 已被翻译
- 好贴要转--bad magic number
- Bad number of channels()
- ZOJ3697-Bad-written Number
- ZOJ3697 Bad-written Number
- Bad version number in .class.....
- ZOJ 3697 Bad-written Number
- ZOJ 3697 Bad-written Number
- OGG-01224 Bad file number
- TortoiseGit Bad file number 解决方法
- Git的Bad file number
- The bad news
- the good,the bad ,the ugly
- Are the Singleton Really Bad
- spring与servlet环境配置
- 111
- UVA572
- 信息驾驶舱(管理驾驶舱)
- POJ1401
- POJ3902 The Bad Number
- Winwebmail能发邮件不能收邮件的解决方法
- android中的动画
- c语言与c++我的初接触
- android OTA
- 在O(1)时间内删除链表节点
- Oracle应用Linux开发C
- 路由
- nasm-64_hello.asm