1. # include <queue>
  2. # include <cstdio>
  3. # include <cstring>
  4. # include <iostream>
  5. # include <algorithm>
  6. using namespace std;
  7.  
  8. int v[4] = {1,10,100,1000},a[100000];
  9.  
  10. struct BigNumber{
  11. int d[1000];
  12. BigNumber() { memset(d,0,sizeof(d)); d[0] = 1; }
  13. BigNumber operator =(const int b){
  14. char s[40];
  15. sprintf(s,"%d",b);
  16. int len = strlen(s);
  17. memset(d,0,sizeof(d));
  18. d[0] = (len - 1)/4 + 1;
  19. for(int i = 0;i < len;i++) d[(len-i-1)/4+1] += (s[i]-'0')*v[(len-i-1)%4];
  20. return *this;
  21. }
  22. void put(){
  23. printf("%d",d[d[0]]);
  24. for(int i = d[0]-1;i >= 1;i--) printf("%04d",d[i]);
  25. printf("\n");
  26. }
  27. };
  28.  
  29. BigNumber operator * (const BigNumber &a,const int &k)
  30. {
  31. BigNumber c;
  32. c.d[0] = a.d[0];
  33. int i ,x = 0;
  34. for(int i = 1;i <=a.d[0];i++){
  35. x = a.d[i]*k + x;
  36. c.d[i] = x%10000;
  37. x /= 10000;
  38. }
  39. while(x > 0){
  40. c.d[++c.d[0]] = x%10000;
  41. x /= 10000;
  42. }
  43. while((c.d[0]>1) && (c.d[c.d[0]] == 0)) --c.d[0];
  44. return c;
  45. }
  46.  
  47. int main()
  48. {
  49. //freopen("a.txt","r",stdin);
  50. //freopen("b.txt","r",stdin);
  51. __int64 n,i;
  52. while(~scanf("%I64d",&n)){
  53. BigNumber ans;
  54. ans = 1;
  55. if(n <= 4){
  56. printf("%d\n",n); continue;
  57. }
  58. //算出n的连续和;
  59. for(i = 2;i < n;i++){
  60. a[i-2] = i;
  61. n -= i;
  62. }
  63.  
  64. int cnt = i - 3;
  65. while(n){
  66. a[cnt]++;
  67. n--;
  68. cnt -= 1;
  69. if(cnt == -1) cnt = i - 3;
  70. }
  71. for(int j = 0;j <= i - 3;j++){
  72. //printf("%d ",a[j]);
  73. ans = ans * a[j];
  74. }
  75. ans.put();
  76. }
  77. return 0;
  78. }

HUNNU-10307-最优分解问题的更多相关文章

  1. gdufs 1237 最优分解问题

    题目链接:http://cstfs.gdufs.edu.cn:8080/JudgeOnline/problem.jsp?id=1237 (好像是内网的0.0) 简单来说,这道题目就是把一个数分解为若干 ...

  2. 【u225】最优分解方案

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] 经过第一轮的游戏,不少同学将会获得圣诞特别礼物,但这时细心的数学课代表发现了一个问题: 留下来的人太多 ...

  3. AC日记——C’s problem(c) TYVJ P4746 (清北学堂2017冬令营入学测试第三题)

    P4746 C’s problem(c)   时间: 1000ms / 空间: 655360KiB / Java类名: Main 背景 冬令营入学测试 描述 题目描述 小C是一名数学家,由于它自制力比 ...

  4. [原]POJ1141 Brackets Sequence (dp动态规划,递归)

    本文出自:http://blog.csdn.net/svitter 原题:http://poj.org/problem?id=1141 题意:输出添加括号最少,并且使其匹配的串. 题解: dp [ i ...

  5. [原]NYOJ 括号匹配系列2,5

    本文出自:http://blog.csdn.net/svitter 括号匹配一:http://acm.nyist.net/JudgeOnline/problem.php?pid=2 括号匹配二:htt ...

  6. BZOJ1263: [SCOI2006]整数划分

    1263: [SCOI2006]整数划分 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 677  Solved: 332[Submit][Status] ...

  7. Sparse Principal Component Analysis via Regularized Low Rank Matrix Approximation(Adjusted Variance)

    目录 前言 文章概述 固定\(\widetilde{\mathrm{v}}\) 固定\(\widetilde{\mathrm{u}}\) Adjusted Variance 前言 这篇文章用的也是交替 ...

  8. Reinforcement Learning for Self Organization and Power Control of Two-Tier Heterogeneous Networks

    R. Amiri, M. A. Almasi, J. G. Andrews and H. Mehrpouyan, "Reinforcement Learning for Self Organ ...

  9. 化繁为简——分解复杂的SQL语句

    今天同事咨询一个SQL语句,如下所示,SQL语句本身并不复杂,但是执行效率非常糟糕,糟糕到一塌糊涂(执行计划也是相当复杂).如果查询条件中没有NOT EXISTS部分,倒是不要一秒就能查询出来. SE ...

随机推荐

  1. 九度oj 题目1031:xxx定律 题目1033:继续xxx定律

    题目描述:     对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数变为1为止.    请计算需要经过几步才能将n变到1,具体可见样例. 输入:     ...

  2. python 写excal

           workbook.save(filename)

  3. 【angularjs学习】简单的语法

    <div ng-app="" ng-init="names=[{name:'Jani',country:'Norway'},{name:'Hege',country ...

  4. PHP文件上传设置和处理(单文件)

    <!--upload.php内容--><?php /* 修改php.ini的设置 file_uploads必须是On upload_max_filesize 设置上传文件的大小,此值 ...

  5. JCaptcha+Memcache的验证码集群实现

    一.问题背景 为了防止垃圾信息发布机器人的自动提交攻击,采用CAPTCHA验证码来保护该模块,提高攻击者的成本. 二.验证码简介 全自动区分计算机和人类的图灵测试(Completely Automat ...

  6. uva 11178二维几何(点与直线、点积叉积)

    Problem D Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states tha ...

  7. 洛谷 [P1995] 程序自动分析

    并查集+ 离散化 首先本题的数据范围很大,需要离散化, STL离散化代码: //dat是原数据,id是编号,sub是数据的副本 sort(sub + 1, sub + tot + 1); size = ...

  8. form表单提交file

    form表单提交文件,这毫无疑问不是个好办法.但是,存在既有意义.既然H5都还让着东西存在着,呢么必然有其意义. form表单中的input type=file这个空间,不得不说奇丑无比!问题是还不能 ...

  9. npm start 修改启动端口的不同方式

    antd的启动配置文件基于package.json文件,配合roadhog使用时,启动配置是: "scripts": { "start": "road ...

  10. js Math [ 随机数、绝对值、四舍五入、进一取整、舍去取整、最大值、最小值、圆周率 ]

    <script> /* 数学对象:Math */ with (document) { write('<br>-3.5的绝对值:'+Math.abs(-3.5)); write( ...