Little Difference Gym
来源:互联网 发布:centos搜狗输入法安装 编辑:程序博客网 时间:2024/05/29 18:15
看了红博大佬的博客。。。
做这个题还是我太慌张。。。 上来想也不想就整了个质因数分解的板子。
赛后才知道就是暴力。。。当然是有技巧的暴力
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <vector>#define inf 0x3f3f3f3f#define ms(x) memset(x, 0, sizeof(x))#define ll long longusing namespace std;const int N = 100007;vector<ll>box[N];int top = 0;bool solve(ll n){ ll tn = n; while(tn%2==0) { tn/=2; } if(tn==1) return false; box[top].push_back(n); for(ll i=2;i*i*i<=n;i++) { if(n%i==0) { ll tmp = n; vector<ll> o ; while(tmp%i==0) { tmp/=i; o.push_back(i); } while(tmp%(i+1)==0) { tmp/=(i+1); o.push_back(i+1); } if(tmp==1) { box[++top] = o; } } } ll ti = sqrt(n); if(ti*ti == n) { box[++top].push_back(ti); box[top].push_back(ti); } else if(ti*(ti+1)==n) { box[++top].push_back(ti); box[top].push_back(ti+1); } else if((ti-1)*(ti)==n) { box[++top].push_back(ti-1); box[top].push_back(ti); } return true;}int main(){ ll n; freopen("little.in","r",stdin); freopen("little.out","w",stdout); scanf("%lld", &n); if(!solve(n)) { puts("-1"); return 0; } printf("%d\n", top+1); for(int i=0;i<=top;i++) { printf("%d",box[i].size()); for(int j=0;j<box[i].size();j++) { printf(" %lld", box[i][j]); } printf("\n"); } return 0;}
阅读全文
0 0
- Little Difference Gym
- Gym 101612L Little Difference 因子分解
- Gym 101612LLittle Difference
- The Little Match Girl Gym
- Difference between big-endian and little-endian
- GYM 101102 B.The Little Match Girl (贪心)
- what is the difference between little-endian and big-endian.
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- 记录Springcloud config的一个坑
- 【《Real-Time Rendering 3rd》 提炼总结】(十) 第十一章 · 非真实感渲染(NPR)相关技术总结
- bootstrap-table的使用
- android studio app 前端获取json数据以对象的形式来解析展示
- 机器人雇员真的来了
- Little Difference Gym
- java poi导入图片问题
- LAMP环境搭建系列之五:编译安装php5.6.32
- Win10查看保存的WiFi密码
- 表单中disabled和readonly的区别
- 《Spring设计思想》AOP设计基本原理
- 文章标题
- Vue—用$refs获取DOM元素+导出Excel
- 通过iText合并pdf