803C Maximal GCD
来源:互联网 发布:python 查数据类型 编辑:程序博客网 时间:2024/06/03 17:00
#include<iostream>#include<vector>#include<string>#include<set>#include<map>#include<algorithm>#include<queue>#include<list>#include<stack>#include<cstdio>#include<fstream>#include<numeric>#include<functional>#include<utility>#include<memory>using namespace std;using namespace placeholders;typedef long long ll;int main(){ll n, k;while (cin >> n >> k){if ((1 + k)*k / 2 > n || k>1000000){cout << "-1" << endl;continue;}vector<ll> factor;for (ll i = 1; i <= sqrt(n); i++){if (n%i == 0){factor.push_back(i);factor.push_back(n / i);}}sort(factor.begin(), factor.end());bool flag = false;vector<ll> result;for (ll i = 0; i < factor.size(); i++){ll sum = k*(k - 1) *factor[i] / 2;ll remain = n - sum;if (remain >(k - 1)*factor[i] && remain%factor[i] == 0){flag = true;result.clear();for (ll j = 1; j < k; j++) result.push_back(j*factor[i]);result.push_back(remain);}else if (remain<(k - 1)*factor[i]){break;}}if (flag){for (int i = 0; i < result.size(); i++) cout << result[i] << " ";cout << endl;}else{cout << "-1" << endl;}}return 0;}
0 0
- 803C Maximal GCD
- codeforces 803C Maximal GCD
- 【Codeforces 803 C. Maximal GCD】
- Codeforces 803C Maximal GCD 题解
- Codeforces 803C Maximal GCD【思维】
- codeforce 803C Maximal GCD(构造)
- CF 803C Maximal GCD 枚举,构造
- Educational Codeforces Round 20-C. Maximal GCD
- Maximal GCD
- Maximal GCD
- Educational Codeforces Round 20 C || Codeforces803C Maximal GCD (水题)
- Codeforces803C Maximal GCD
- Codeforces803C Maximal GCD 思维
- Maximal GCD CodeForces
- CF803C:Maximal GCD(思维 & 构造)
- 【LeetCode】【C++】Maximal Rectangle
- 【C++】LeetCode 85. Maximal Rectangle
- [leetcode-85]Maximal Rectangle(c++)
- 不是图论 【tarjan求scc】+【缩点】
- 一个 简单的本地局域网投票小Servlet
- C++抽象编程——接口(6)——设置随机数种子
- 用CSS实现3D魔方动画旋转
- 自定义分页
- 803C Maximal GCD
- 二哥 <LINUX内核设计与实现> 阅读笔记 一
- 矩形覆盖
- Git 常用命令大全
- QT+opencv实现人脸检测并提取裁剪
- 3533---->League of Legends
- Angular自定义过滤器
- android_Class_Color
- [leetcode]: 461. Hamming Distance