【瞎搞题】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]钦点题解--瞎搞+链表 题目链接 于 暴 力 过
随机推荐
- 【C语言】符号优先级
一. 问题的引出 今天看阿里的笔试题,看到一个非常有意思的题目,但是很容易出错. 题目:如下函数,在32bit系统foo(2^31-3)的值是: Int foo(int x) { return x&a ...
- Nginx 指令目录(中文版)
指令大全 accept_mutex accept_mutex_delay access_log add_after_body add_before_body add_header addition_t ...
- Docker 以 docker 方式运行 jenkins
https://testerhome.com/topics/5798 Docker 以 docker 方式运行 jenkins jmcn · 2016年08月26日 · 最后由 blueshark 回 ...
- SNF开发平台WinForm-Grid表格控件大全
我们在开发系统时,会有很多种控件进行展示,甚至有一些为了方便的一些特殊需求. 那么下面就介绍一些我们在表格控件里常用的方便的控件: 1.Grid表格查询条 Grid表格下拉 3.Grid表格弹框选 ...
- SNF快速开发平台--规则引擎在程序当中如何调用
规则定义完如何在程序当中进行使用呢? 其时很简单,只需要如下代码就可以调用程序: 规则定义: 调用代码: #region 演示2:生成左表数据(规则) POST: /api/DEMO/DemoSing ...
- 揭开Docker的神秘面纱
Docker 相信在飞速发展的今天已经越来越火,它已成为如今各大企业都争相使用的技术.那么Docker 是什么呢?为什么这么多人开始使用Docker? 本节课我们将一起解开Docker的神秘面纱. 本 ...
- vue使用方法计算总金额
1.预览 2.index.html <!DOCTYPE html> <html lang="en"> <head> <meta chars ...
- MAC /usr/local 文件夹权限问题
修改文件夹权限 sudo chown -R $(whoami) /usr/local/ 如果失败提示Operation not permitted 或其他权限不足,则需要关闭Rootless Root ...
- Java知多少(41)泛型详解
我们知道,使用变量之前要定义,定义一个变量时必须要指明它的数据类型,什么样的数据类型赋给什么样的值. 假如我们现在要定义一个类来表示坐标,要求坐标的数据类型可以是整数.小数和字符串,例如: x = 1 ...
- 如何停止和禁用Linux系统中的不需要的服务
从Linux中删除不需要的服务 在本文中,我们将讨论一些您不需要的不需要的应用程序和服务,但它们是在操作系统安装期间默认安装的,并且不知不觉地开始吃您的系统资源. 让我们首先知道使用以下命令在系统上运 ...