ZOJ2345Gold Coins
昨天做过一样的题:
平方和公式:n*(n+1)*(2n+1)/6
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
int a[],num;
int b[];
int _S()
{
char c=getchar();int s=;
while(c<''||c>'') c=getchar();
while(c>=''&&c<=''){s=s*+c-'';c=getchar();}
return s;
}
void _db()
{
for(int i=;i<=;i++)
a[i]=(i+)*i/;
for(int i=;i<=;i++)
b[i]=i*(i+)*(*i+)/;
return ;
}
void _get(int v)
{
int tmp,ans;
for(int i=;i<=;i++)
if(a[i]<=v) tmp=i;//当然也可以用二分查找或者lower_bound
ans=b[tmp];
ans+=(v-a[tmp])*(tmp+);
printf("%d %d\n",v,ans);
return ;
}
int main()
{
_db();
int T,n,x;
T=_S();
while(T--){
while(true){
x=_S();
if(x==) break;
_get(x);
}
if(T) printf("\n");
}
return ;
}
ZOJ2345Gold Coins的更多相关文章
- ZOJ2345Gold Coins 简单分块
昨天做过一样的题: 平方和公式:n*(n+1)*(2n+1) #include<cstdio> #include<cstdlib> #include<iostream&g ...
- [LeetCode] Arranging Coins 排列硬币
You have a total of n coins that you want to form in a staircase shape, where every k-th row must ha ...
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- Codeforces 2016 ACM Amman Collegiate Programming Contest A. Coins(动态规划/01背包变形)
传送门 Description Hasan and Bahosain want to buy a new video game, they want to share the expenses. Ha ...
- csuoj 1119: Collecting Coins
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1119 1119: Collecting Coins Time Limit: 3 Sec Memo ...
- Coins
Description Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hi ...
- hdu 1398 Square Coins (母函数)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- (混合背包 多重背包+完全背包)The Fewest Coins (poj 3260)
http://poj.org/problem?id=3260 Description Farmer John has gone to town to buy some farm supplies. ...
- POJ3260The Fewest Coins[背包]
The Fewest Coins Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 6299 Accepted: 1922 ...
随机推荐
- C89_一些函数
C89 string.h 中的函数: 复制函数 memcpy memmove strcpy strncpy 串接函数 strcat strncat 比较函数 memcmp strcmp strcoll ...
- SpringBoot导入excle文件数据
本文主要描述,Springboot框架下上传excel,处理里面相关数据做逻辑分析,由于用到的是前后端分离技术,这里记录的主要是后端java部分,通过与前端接口进行对接实现功能 1.在pom.xml文 ...
- 雷林鹏分享:C# 属性(Property)
C# 属性(Property) 属性(Property) 是类(class).结构(structure)和接口(interface)的命名(named)成员.类或结构中的成员变量或方法称为 域(Fie ...
- 单细胞 RNA-seq 10X Genomics
单细胞流程跑了不少,但依旧看不懂结果,是该好好补补了. 有些人可能会误会,觉得单细胞的RNA-seq数据很好分析,跟分析常规的RNA-seq应该没什么区别.今天的这篇文章2015年3月发表在Natur ...
- English trip -- VC(情景课) 7 A Shopping 购物
Words The clothes place a dress 长裙 short skirt 短裙 pants 裤子 / trousers 长裤 / shorts 短裤 a shir ...
- 3.6 MIPS指令简介
计算机组成 3 指令系统体系结构 3.6 MIPS指令简介 MIPS秉承着指令数量少,指令功能简单的设计理念.那这样的设计理念是如何实现的呢?在这一节,我们就将来分析MIPS指令的特点. 相比于X86 ...
- hdu 2266 dfs+1258
How Many Equations Can You Find Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 ...
- CoderForce 180D-Name (构造+回溯)
题目大意:给两个字符串s,t,用s中的字符重新组合构造出按字典序最小的但比t大的新字符串. 题目分析:先统计s中各个字母出现的次数,然后从t的左端向右端依次构造出新串的每一位上的字母.这个过程我是用回 ...
- Oracle性能诊断艺术-读书笔记
create table test0605 as select * from dba_objects; select t1.owner,t1.object_name,t1.object_id from ...
- STM32F103各PIN脚封装图
1.36PIN 2.48PIN 3.64PIN 4.100PIN STM32ZET6详细pin脚图