Codeforces 347E - Number Transformation II
来源:互联网 发布:日本杀人知乎 编辑:程序博客网 时间:2024/05/18 03:35
给出
每一步可以做两个操作其中一个
1 将
2 将
问将
每次贪心的找到能减到的最小的大于等于
如果一个
#include<bits/stdc++.h>using namespace std;set<int> S;int main(){ int a,b,n; int x; scanf("%d",&n); while(n--){ scanf("%d",&x); S.insert(x); } scanf("%d %d",&a,&b); int tim = 0; while(a != b){ int mi = a - 1; for(set<int>::iterator it = S.begin();it != S.end(); ){ int x = *it; it++; if(a - a % x < b) S.erase(x); else mi = min(mi,a - a % x); } a = mi; tim++; } printf("%d\n",tim); return 0;}
0 0
- Codeforces 347E - Number Transformation II
- codeforces 347 E Number Transformation II
- codeforces Number Transformation II
- Number Transformation II CodeForces
- Codeforces Round #201 (Div. 2) E - Number Transformation II
- Codeforces 346C Number Transformation II 构造
- CodeForces346 C. Number Transformation II
- Codeforces Round #201 (Div. 1) C. Number Transformation II(思路)
- codeforces 251C Number Transformation(数论)
- [Codefoces 251C & 252E]Number Transformation dp+循环节
- Number Transformation
- Number Transformation
- Number Transformation
- CSUOJ 1299 - Number Transformation II 打表预处理水DP
- Codeforces Round #153 (Div. 1) C. Number Transformation
- Codeforces Round #153 (Div. 1) C Number Transformation bfs
- codeforces 251C C. Number Transformation(数论+dp)
- Codeforces 441 E. Valera and Number
- sleep与usleep的区别
- LeetCode 326. Power of Three 解题报告
- 第九周oj2
- Openwrt 修改Mac地址
- Java 获取jar 绝对路径方法
- Codeforces 347E - Number Transformation II
- OneProxy安装部署和分表简测
- Rx JAVA在安卓中的使用
- Spring Boot Profile使用
- Android跟我一起来开发--微影之架构补充篇
- 网页设计师必知的10则SEO
- windows服务器安装sftp 教程及注意事项
- Installation failed with message INSTALL_FAILED_USER_RESTRICTED错误
- 开放平台的一些想法