【瞎搞题】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]钦点题解--瞎搞+链表 题目链接 于 暴 力 过
随机推荐
- iOS开发之Xcode9报错 Compiling IB documents for earlier than iOS7 is no longer supported.
升级到Xcode9时,最低的编译版本为iOS8,但是在使用一些SDK的时候就会报出Compiling IB documents for earlier than iOS7 is no longer s ...
- NodeJs相关系列文章
1.图片上传之FileAPI与NodeJs 2.NodeJs之调试 3.CentOS下使用NVM 4.NodeJs之进程守护 5.Ubuntu下使用nvm 6.NodeJs之pm2 7.NodeJs之 ...
- Android Studio配置Android Annotations框架详解--说说那些坑
我们开发过程中都需要写些findViewByid.serOnclickListener等类似的代码,虽然不费事,但是一个项目下来,工作量还是很大的.为了节省工作量,运生了很多对应的注解框架.网上的博客 ...
- EasyUI - DataGrid 去右边空白滚动条列
在网上查了很长时间没有找到解决方法,干脆自已查看一下代码来解决吧,随是压缩过的,不过也还是好查的,工夫不负有心人,终于解决了,方法如下: 一.我们先让表格自适应宽度 <!DOCTYPE html ...
- [转]Unity手游之路<十二>手游资源热更新策略探讨
最近梳理了下游戏流程.恩,本来想写下,但是,还是看前辈的吧 版权声明: https://blog.csdn.net/janeky/article/details/17666409 上一次我们学习了如何 ...
- Jquery计算指定日期加上多少天、加多少月、加多少年的日期
/* * 功能:实现VBScript的DateAdd功能. * 参数:interval,字符串表达式,表示要添加的时间间隔. * 参数:number,数值表达式,表示要添加的时间间隔的个数. * 参数 ...
- Java知多少(10)数据类型及变量
Java 是一种“强类型”的语言,声明变量时必须指明数据类型.变量(variable)占据一定的内存空间.不同类型的变量占据不同的大小. Java中共有8种基本数据类型,包括4 种整型.2 种浮点型. ...
- Scala学习笔记(五):内建控制循环
前言 Scala中内建控制循环包括if.while.for.try.match和函数调用. if和while与java类似,不做介绍. for 基础用法 def main(args: Array[St ...
- fiddler配置手机抓包
参考:https://blog.csdn.net/gld824125233/article/details/52588275 注:我内部用,没有https,不用配置https证书.
- 中小学教育缴费----支付宝回传数据.net core 接收中文乱码
问题描述: 中小学教育缴费,发送账单到家长支付宝,家长支付成功之后,支付宝回传数据,验签的时候失败了,排查之后发现账单名称乱码了.支付宝回传的时候中文传的是GBK编码格式,但是我接收的是%D5˵%A5 ...