HUNNU-10307-最优分解问题
- # include <queue>
- # include <cstdio>
- # include <cstring>
- # include <iostream>
- # include <algorithm>
- using namespace std;
- int v[4] = {1,10,100,1000},a[100000];
- struct BigNumber{
- int d[1000];
- BigNumber() { memset(d,0,sizeof(d)); d[0] = 1; }
- BigNumber operator =(const int b){
- char s[40];
- sprintf(s,"%d",b);
- int len = strlen(s);
- memset(d,0,sizeof(d));
- d[0] = (len - 1)/4 + 1;
- for(int i = 0;i < len;i++) d[(len-i-1)/4+1] += (s[i]-'0')*v[(len-i-1)%4];
- return *this;
- }
- void put(){
- printf("%d",d[d[0]]);
- for(int i = d[0]-1;i >= 1;i--) printf("%04d",d[i]);
- printf("\n");
- }
- };
- BigNumber operator * (const BigNumber &a,const int &k)
- {
- BigNumber c;
- c.d[0] = a.d[0];
- int i ,x = 0;
- for(int i = 1;i <=a.d[0];i++){
- x = a.d[i]*k + x;
- c.d[i] = x%10000;
- x /= 10000;
- }
- while(x > 0){
- c.d[++c.d[0]] = x%10000;
- x /= 10000;
- }
- while((c.d[0]>1) && (c.d[c.d[0]] == 0)) --c.d[0];
- return c;
- }
- int main()
- {
- //freopen("a.txt","r",stdin);
- //freopen("b.txt","r",stdin);
- __int64 n,i;
- while(~scanf("%I64d",&n)){
- BigNumber ans;
- ans = 1;
- if(n <= 4){
- printf("%d\n",n); continue;
- }
- //算出n的连续和;
- for(i = 2;i < n;i++){
- a[i-2] = i;
- n -= i;
- }
- int cnt = i - 3;
- while(n){
- a[cnt]++;
- n--;
- cnt -= 1;
- if(cnt == -1) cnt = i - 3;
- }
- for(int j = 0;j <= i - 3;j++){
- //printf("%d ",a[j]);
- ans = ans * a[j];
- }
- ans.put();
- }
- return 0;
- }
HUNNU-10307-最优分解问题的更多相关文章
- gdufs 1237 最优分解问题
题目链接:http://cstfs.gdufs.edu.cn:8080/JudgeOnline/problem.jsp?id=1237 (好像是内网的0.0) 简单来说,这道题目就是把一个数分解为若干 ...
- 【u225】最优分解方案
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 经过第一轮的游戏,不少同学将会获得圣诞特别礼物,但这时细心的数学课代表发现了一个问题: 留下来的人太多 ...
- AC日记——C’s problem(c) TYVJ P4746 (清北学堂2017冬令营入学测试第三题)
P4746 C’s problem(c) 时间: 1000ms / 空间: 655360KiB / Java类名: Main 背景 冬令营入学测试 描述 题目描述 小C是一名数学家,由于它自制力比 ...
- [原]POJ1141 Brackets Sequence (dp动态规划,递归)
本文出自:http://blog.csdn.net/svitter 原题:http://poj.org/problem?id=1141 题意:输出添加括号最少,并且使其匹配的串. 题解: dp [ i ...
- [原]NYOJ 括号匹配系列2,5
本文出自:http://blog.csdn.net/svitter 括号匹配一:http://acm.nyist.net/JudgeOnline/problem.php?pid=2 括号匹配二:htt ...
- BZOJ1263: [SCOI2006]整数划分
1263: [SCOI2006]整数划分 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 677 Solved: 332[Submit][Status] ...
- Sparse Principal Component Analysis via Regularized Low Rank Matrix Approximation(Adjusted Variance)
目录 前言 文章概述 固定\(\widetilde{\mathrm{v}}\) 固定\(\widetilde{\mathrm{u}}\) Adjusted Variance 前言 这篇文章用的也是交替 ...
- 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 ...
- 化繁为简——分解复杂的SQL语句
今天同事咨询一个SQL语句,如下所示,SQL语句本身并不复杂,但是执行效率非常糟糕,糟糕到一塌糊涂(执行计划也是相当复杂).如果查询条件中没有NOT EXISTS部分,倒是不要一秒就能查询出来. SE ...
随机推荐
- 九度oj 题目1031:xxx定律 题目1033:继续xxx定律
题目描述: 对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数变为1为止. 请计算需要经过几步才能将n变到1,具体可见样例. 输入: ...
- python 写excal
workbook.save(filename)
- 【angularjs学习】简单的语法
<div ng-app="" ng-init="names=[{name:'Jani',country:'Norway'},{name:'Hege',country ...
- PHP文件上传设置和处理(单文件)
<!--upload.php内容--><?php /* 修改php.ini的设置 file_uploads必须是On upload_max_filesize 设置上传文件的大小,此值 ...
- JCaptcha+Memcache的验证码集群实现
一.问题背景 为了防止垃圾信息发布机器人的自动提交攻击,采用CAPTCHA验证码来保护该模块,提高攻击者的成本. 二.验证码简介 全自动区分计算机和人类的图灵测试(Completely Automat ...
- uva 11178二维几何(点与直线、点积叉积)
Problem D Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states tha ...
- 洛谷 [P1995] 程序自动分析
并查集+ 离散化 首先本题的数据范围很大,需要离散化, STL离散化代码: //dat是原数据,id是编号,sub是数据的副本 sort(sub + 1, sub + tot + 1); size = ...
- form表单提交file
form表单提交文件,这毫无疑问不是个好办法.但是,存在既有意义.既然H5都还让着东西存在着,呢么必然有其意义. form表单中的input type=file这个空间,不得不说奇丑无比!问题是还不能 ...
- npm start 修改启动端口的不同方式
antd的启动配置文件基于package.json文件,配合roadhog使用时,启动配置是: "scripts": { "start": "road ...
- js Math [ 随机数、绝对值、四舍五入、进一取整、舍去取整、最大值、最小值、圆周率 ]
<script> /* 数学对象:Math */ with (document) { write('<br>-3.5的绝对值:'+Math.abs(-3.5)); write( ...