【瞎搞题】gym226123 L. For the Honest Election
http://codeforces.com/gym/226123/problem/L
题解:手摸几组数据,发现一个规律:将n 质因数分解,答案就是 每个质因数/2+1后再乘起来。
然后考虑2的情况:
2 | 8 | 16 | 32 | 64 |
1 | 5 | 9 | 15 | 25 |
发现 2,16 要特判 另外8的因子对应乘5
交上去又发现表格填错了,2 对应的是2 不是1 然后就AC了。 正常做法是dfs
#define _CRT_SECURE_NO_WARNINGS
#include<cmath>
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
using namespace std;
#define rep(i,t,n) for(int i =(t);i<=(n);++i)
#define per(i,n,t) for(int i =(n);i>=(t);--i)
#define mmm(a,b) memset(a,b,sizeof(a))
#define eps 1e-6
const int maxn = 1e6+;
int a[maxn];
int isp[maxn];
int cnt[maxn];
typedef long long ll;
struct node { }; ll n;
ll ans = n / + ;
void run(int n) {
ans = n / + ;
for (ll i = ; i*i <= n; i++)if (n%i == ) {
ll x = (i / + )*(((n / i) / ) + );
ans = min(ans, x);
}
}
int main() {
rep(i, , maxn)isp[i] = ;
rep(i, , maxn)if (isp[i]) {
for (int j = * i; j <= maxn; j += i)isp[j] = ;
} while (cin >> n)
{ ll ans = ; int cnt=;
while (n % == )n /= , cnt++;
while (cnt >= ) {
if (cnt == ) { cnt -= ; ans *= ; }
else { cnt -= ; ans *= ; }
}
if (cnt == ) { ans *= ; }
if (cnt == )ans *= ; rep(i, , maxn-) if(isp[i]){
while (n%i == )ans *= (i/ + ),n/=i;
if (n == )break;
}
ans *= (n/+);
cout << ans;
}
} /*
qwer
qwre
1000000000
*/
dfs:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
map<int,int>sp;
void solve(int t){
if(sp[t])return ;
sp[t]=t/+;
for(int i=;i*i<=t;i++){
if(t%i==){
solve(t/i);
solve(i);
sp[t]=min(sp[t],sp[t/i]*(i/+));
sp[t]=min(sp[t],sp[i]*(t/i/+));
}
}
}
int main(){
int n,i,j;
scanf("%d",&n);
solve(n);
printf("%d\n",sp[n]);
return ;
}
【瞎搞题】gym226123 L. For the Honest Election的更多相关文章
- HDU 4923 Room and Moor(瞎搞题)
瞎搞题啊.找出1 1 0 0这样的序列,然后存起来,这样的情况下最好的选择是1的个数除以这段的总和. 然后从前向后扫一遍.变扫边进行合并.每次合并.合并的是他的前驱.这样到最后从t-1找出的那条链就是 ...
- B. Salty Fish Go! -期望题(瞎搞题)
链接:https://www.nowcoder.com/acm/contest/104/B来源:牛客网 题意:A few days ago, WRD was playing a small game ...
- 简单瞎搞题(bitset的操作)
链接:https://www.nowcoder.com/acm/contest/132/C来源:牛客网 题目 一共有 n个数,第 i 个数是 xi xi 可以取 [li , ri] 中任意的一个值. ...
- 牛客练习赛22 简单瞎搞题(bitset优化dp)
一共有 n个数,第 i 个数是 xi xi 可以取 [li , ri] 中任意的一个值. 设 ,求 S 种类数. 输入描述: 第一行一个数 n. 然后 n 行,每行两个数表示 li,ri. 输出 ...
- 牛客练习赛22 C 简单瞎搞题
//位运算 // & 都是1 才是 1 // | 都是0 才是0 // ^ 不一样才是1 #include <iostream> #include <cstdio> # ...
- 牛客 132C 简单瞎搞题 (bitset)
大意: 给定序列$a$的第$i$个元素的取值范围$[L_i,R_i]$, 求$a$的平方和的种类数. 用bitset优化, 复杂度$O(\frac{n^5}{\omega})$ #include &l ...
- TOJ3097: 单词后缀 (字典树 or map瞎搞)
传送门 (<---可以点击的~) 时间限制(普通/Java):1000MS/3000MS 内存限制:65536KByte 描述 有些英语单词后缀都是一样的,现在我们需要从给定的一堆单词里 ...
- ubuntu--基础环境瞎搞集合
安装ubuntu系统后有很多东西需要自己瞎搞一下,这里把一些瞎搞的过程记录在这里,方便以后重新装系统后重新配置. 一.安装. 可以在windows下制作启动盘(软碟通),然后开机u盘启动即可安装,预留 ...
- [JZOJ5281]钦点题解--瞎搞+链表
[JZOJ5281]钦点题解--瞎搞+链表 题目链接 于 暴 力 过
随机推荐
- spring-mybatis-data-common程序级分表操作实例
spring-mybatis-data-common-2.0新增分表机制,在1.0基础上做了部分调整. 基于机架展示分库应用数据库分表实力创建 create table tb_example_1( i ...
- MDK-ARM输出HEX文件重命名设置
输出的可执行文件和库的名称就是在这里定义.比如我们常见输出Hex文件,其名称就是这里定义的.
- sringboot项目在tomcat上的部署
sringboot项目在tomcat上的部署原文链接: https://blog.csdn.net/zhaoyahui_666/article/details/78283559#comments 20 ...
- 第一部分:开发前的准备-第八章 Android SDK与源码下载
第8章 Android SDK与源码下载 如果你是新下载的SDK,请阅读一下步骤了解如何设置SDK.如果你已经下载使用过SDK,那么你应该使用AVD Manager,来更新即可. 下面是构建Andro ...
- 用Python来玩微信跳一跳
微信2017年12月28日发布了新版本,在小程序里面有一个跳一跳小游戏,试着点一点玩了下.第二天刚好在一篇技术公众号中,看到有大神用Python代码计算出按压时间,向手机发送android adb命令 ...
- 导出不带.svn的文件夹或者是不含.class的文件
转载自:http://blog.csdn.net/z278718149/article/details/21537395 如何导出不带.svn的文件夹或者是不含.class的文件 在工作环境中,有的时 ...
- [php] thinkphp基于Http类 下载文件
http://blog.csdn.net/u010081689/article/details/49360937
- Android美丽的对话框项目sweet-alert-dialog
美丽的对话框 sweet-alert-dialog 项目地址: https://github.com/pedant/sweet-alert-dialog android原生的dialog太生硬了,之前 ...
- 【转】数据分析sql常用整理
[SQL 数据分析常用语句] • 1 基础查询 • 2 字符串数字日期时间 • 3 聚合数据查询 • 4 子查询 • 5 联接组合查询 • 6 高级查询 • 7 更新数据 阅读提醒:点击图片放大可看清 ...
- c++类成员函数后边加const是为什么?
时间是让人猝不及防的东西,晴是有风阴时有雨,争不过朝夕,又念着往昔,偷走了青丝却留住一个你 #include <iostream> #include <string> usin ...