http://codeforces.com/gym/226123/problem/L

题解:手摸几组数据,发现一个规律:将n 质因数分解,答案就是 每个质因数/2+1后再乘起来。

  然后考虑2的情况:

2 8 16 32 64
1 5 9 15 25
  1. 发现 216 要特判  另外8的因子对应乘5
  1. 交上去又发现表格填错了,2 对应的是2 不是1  然后就AC了。 正常做法是dfs
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<cmath>
  3. #include<iostream>
  4. #include<stdio.h>
  5. #include<algorithm>
  6. #include<cstring>
  7. using namespace std;
  8. #define rep(i,t,n) for(int i =(t);i<=(n);++i)
  9. #define per(i,n,t) for(int i =(n);i>=(t);--i)
  10. #define mmm(a,b) memset(a,b,sizeof(a))
  11. #define eps 1e-6
  12. const int maxn = 1e6+;
  13. int a[maxn];
  14. int isp[maxn];
  15. int cnt[maxn];
  16. typedef long long ll;
  17. struct node {
  18.  
  19. };
  20.  
  21. ll n;
  22. ll ans = n / + ;
  23. void run(int n) {
  24. ans = n / + ;
  25. for (ll i = ; i*i <= n; i++)if (n%i == ) {
  26. ll x = (i / + )*(((n / i) / ) + );
  27. ans = min(ans, x);
  28. }
  29. }
  30. int main() {
  31. rep(i, , maxn)isp[i] = ;
  32. rep(i, , maxn)if (isp[i]) {
  33. for (int j = * i; j <= maxn; j += i)isp[j] = ;
  34. }
  35.  
  36. while (cin >> n)
  37. {
  38.  
  39. ll ans = ;
  40.  
  41. int cnt=;
  42. while (n % == )n /= , cnt++;
  43. while (cnt >= ) {
  44. if (cnt == ) { cnt -= ; ans *= ; }
  45. else { cnt -= ; ans *= ; }
  46. }
  47. if (cnt == ) { ans *= ; }
  48. if (cnt == )ans *= ;
  49.  
  50. rep(i, , maxn-) if(isp[i]){
  51. while (n%i == )ans *= (i/ + ),n/=i;
  52. if (n == )break;
  53. }
  54. ans *= (n/+);
  55. cout << ans;
  56. }
  57. }
  58.  
  59. /*
  60. qwer
  61. qwre
  62. 1000000000
  63. */

dfs:

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<algorithm>
  5. #include<vector>
  6. #include<map>
  7. #include<queue>
  8. using namespace std;
  9. typedef long long ll;
  10. map<int,int>sp;
  11. void solve(int t){
  12. if(sp[t])return ;
  13. sp[t]=t/+;
  14. for(int i=;i*i<=t;i++){
  15. if(t%i==){
  16. solve(t/i);
  17. solve(i);
  18. sp[t]=min(sp[t],sp[t/i]*(i/+));
  19. sp[t]=min(sp[t],sp[i]*(t/i/+));
  20. }
  21. }
  22. }
  23. int main(){
  24. int n,i,j;
  25. scanf("%d",&n);
  26. solve(n);
  27. printf("%d\n",sp[n]);
  28. return ;
  29. }

【瞎搞题】gym226123 L. For the Honest Election的更多相关文章

  1. HDU 4923 Room and Moor(瞎搞题)

    瞎搞题啊.找出1 1 0 0这样的序列,然后存起来,这样的情况下最好的选择是1的个数除以这段的总和. 然后从前向后扫一遍.变扫边进行合并.每次合并.合并的是他的前驱.这样到最后从t-1找出的那条链就是 ...

  2. B. Salty Fish Go! -期望题(瞎搞题)

    链接:https://www.nowcoder.com/acm/contest/104/B来源:牛客网 题意:A few days ago, WRD was playing a small game ...

  3. 简单瞎搞题(bitset的操作)

    链接:https://www.nowcoder.com/acm/contest/132/C来源:牛客网 题目 一共有 n个数,第 i 个数是 xi  xi 可以取 [li , ri] 中任意的一个值. ...

  4. 牛客练习赛22 简单瞎搞题(bitset优化dp)

    一共有 n个数,第 i 个数是 xi  xi 可以取 [li , ri] 中任意的一个值. 设 ,求 S 种类数. 输入描述: 第一行一个数 n. 然后 n 行,每行两个数表示 li,ri.   输出 ...

  5. 牛客练习赛22 C 简单瞎搞题

    //位运算 // & 都是1 才是 1 // | 都是0 才是0 // ^ 不一样才是1 #include <iostream> #include <cstdio> # ...

  6. 牛客 132C 简单瞎搞题 (bitset)

    大意: 给定序列$a$的第$i$个元素的取值范围$[L_i,R_i]$, 求$a$的平方和的种类数. 用bitset优化, 复杂度$O(\frac{n^5}{\omega})$ #include &l ...

  7. TOJ3097: 单词后缀 (字典树 or map瞎搞)

    传送门 (<---可以点击的~) 时间限制(普通/Java):1000MS/3000MS     内存限制:65536KByte 描述 有些英语单词后缀都是一样的,现在我们需要从给定的一堆单词里 ...

  8. ubuntu--基础环境瞎搞集合

    安装ubuntu系统后有很多东西需要自己瞎搞一下,这里把一些瞎搞的过程记录在这里,方便以后重新装系统后重新配置. 一.安装. 可以在windows下制作启动盘(软碟通),然后开机u盘启动即可安装,预留 ...

  9. [JZOJ5281]钦点题解--瞎搞+链表

    [JZOJ5281]钦点题解--瞎搞+链表 题目链接 于 暴 力 过

随机推荐

  1. Java定时任务示例

    package com.my.timer; import java.util.Date; import java.util.TimerTask; public class myTask extends ...

  2. 各种软件的安装教程centos mysql tomcat nginx jenkins jira 等等

    464  Star3,606 Fork 1,460 judasn/Linux-Tutorial 作者: https://github.com/judasn Linux-Tutorial/markdow ...

  3. A Tale of Three Apache Spark APIs: RDDs, DataFrames, and Datasets(中英双语)

    文章标题 A Tale of Three Apache Spark APIs: RDDs, DataFrames, and Datasets 且谈Apache Spark的API三剑客:RDD.Dat ...

  4. Git教程学习(一)

    教程来自: Git教程(廖雪峰的官方网站) 学习Git的基本内容,对教程内容进行理解并脱水 1. Git简介 2. 安装Git 1. ubuntu上安装Git $ sudo apt-get insta ...

  5. Android Studio 插件(plugins)或者intellij idea 插件(plugins)无法安装

    通常这种情况出现都因为idea.properties修改了 idea.system.path=${指定路径}/system idea.plugins.path=${idea.config.path}/ ...

  6. 第三部分:Android 应用程序接口指南---第二节:UI---第九章 搜索

    第9章 搜索 在android平台上搜索是一个核心的用户功能.无论内容位于设备或网络上,用户应该能够搜索任何对它们可用的数据.为了创建一个一致的用户搜索体验,Android平台提供了一个搜索框架帮助你 ...

  7. Android studio的主题颜色修改

    1.选择喜欢的主题 http://color-themes.com/?view=index 好几十款,总有一款你喜欢 2.下载你喜欢的主题,注意是jar文件 .File -> Import Se ...

  8. 菜鸟要做架构师(二)——java性能优化之for循环

    完成同样的功能,用不同的代码来实现,性能上可能会有比较大的差别,所以对于一些性能敏感的模块来说,对代码进行一定的优化还是很有必要的.今天就来说一下java代码优化的事情,今天主要聊一下对于for(wh ...

  9. ceph 的 bufferlist

    bufferlist是buffer::list的别名,其由来在 http://bean-li.github.io/bufferlist-in-ceph/ 中有非常详细的介绍 其p.p_off.off字 ...

  10. oracle结合mybatis批量插入数据

    先上代码: controller: result = service.insertTRbXdhjLendYdData(params); service: List<TRbXdhjLendDTO& ...