第十周 5.2 --- 5.8
2016-05-02 19:29
387 查看
似乎什么都没干就半期了...
5.2
B.卿学姐与基本法
离散化
卡了好几天,,学了一种有一点点不一样的离散化
写挫还是犯了和寒假一样的错,离散化之后,update (1,1,tot)而不是那个 n 了
View Code
补完水题,补不动了.........................
5.2
B.卿学姐与基本法
离散化
卡了好几天,,学了一种有一点点不一样的离散化
写挫还是犯了和寒假一样的错,离散化之后,update (1,1,tot)而不是那个 n 了
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<vector> #include<set> using namespace std; int n; multiset<int> s; const int maxn = 1e2+5; int a[maxn],cnt; void fenjie( int x){ int y = x; for(int j = 2;j*j <= y;j++){ if(y%j == 0){ while(y%j == 0){ a[++cnt] = j; y = y/j; if(cnt == 2) return; } if(cnt == 2) return; } } if(y > 1) a[++cnt] = y; } void solve(){ n = n-3; if(n == 0){ puts("4"); return; } if(n < 4){ puts("No such base"); return; } int y = n; cnt = 0; memset(a,0,sizeof(a)); fenjie(y); if(a[1] > 3){ printf("%d\n",a[1]); return; } if(a[1]*a[2] > 3){ printf("%d\n",a[1]*a[2]); return; } printf("No such base\n"); } int main(){ while(scanf("%d",&n)){ if(n == 0) break; solve(); } return 0; }
View Code
补完水题,补不动了.........................
相关文章推荐
- Docke开山篇
- [BZOJ2440][中山市选2011]完全平方数(二分+容斥原理)
- NYOJ99单词拼接(欧拉通路回路,dfs打印路径)
- leetcode 073 Set Matrix Zeroes
- XML的解析
- 快速点击两次退出应用
- Just a Hook---hdu1698(线段树---区间处理)
- iOS App icon、启动页、图标规范
- 【操作系统】OS的整体框架
- hiho#1050 : 树中的最长路
- c语言学生信息管理系统学习感想
- 如何成为一个牛逼的C/C++程序员?
- poj 1562 Oil Deposits(dfs)
- jsp集成markdown编辑器
- WebService核心文件【server-config.wsdd】详解及调用示例
- SharedPreference.Editor 的 apply() 和 commit() 的区别
- 正则表达式——Regular Expression
- 优先队列
- Android自定义属性
- C# winform中文本框限制只能输入数字和字母,退格键