Best code水题之路
2016-07-18 11:27
309 查看
BestCoder 2nd Anniversary:
1001.Oracle
There is once a king and queen, rulers of an unnamed city, who have three daughters of conspicuous beauty.
The youngest and most beautiful is Psyche, whose admirers, neglecting the proper worship of the love goddess Venus, instead pray and make offerings to her. Her father, the king, is desperate to know about her destiny, so he comes to the Delphi Temple to ask for an oracle.
The oracle is an integer n n n without leading zeroes.
To get the meaning, he needs to rearrange the digits and split the number into two positive integers without leading zeroes, and their sum should be as large as possible.
Help him to work out the maximum sum. It might be impossible to do that. If so, print
数据比较大,用字符串输入,要处理进位
View Code(16/7/17)
1001.Oracle
There is once a king and queen, rulers of an unnamed city, who have three daughters of conspicuous beauty.
The youngest and most beautiful is Psyche, whose admirers, neglecting the proper worship of the love goddess Venus, instead pray and make offerings to her. Her father, the king, is desperate to know about her destiny, so he comes to the Delphi Temple to ask for an oracle.
The oracle is an integer n n n without leading zeroes.
To get the meaning, he needs to rearrange the digits and split the number into two positive integers without leading zeroes, and their sum should be as large as possible.
Help him to work out the maximum sum. It might be impossible to do that. If so, print
Uncertain.
数据比较大,用字符串输入,要处理进位
#include<stdio.h> #include<string.h> #include<string> #include<iostream> #include<algorithm> #include<math.h> #include<stdlib.h> using namespace std; #define LL long long #define M 100010 #define inf 0x7f7f7f7f #define PI 3.1415926 #define mod 1000000007 int n,m; int a[25]; void dfs() { } int main() { scanf("%d",&n); while(n--) { int sum=0,ave=0; scanf("%d",&m); for(int i=0;i<m;i++) { scanf("%d",&a[i]); sum+=a[i]; } ave=sum/4; sort(a,a+m); if(sum%4||ave<a[m-1]||m<4) { printf("no\n"); continue; } } }
View Code(16/7/17)
相关文章推荐
- 集训——挑战(P18,Poj NO.1852)
- javascript DOM对象
- 优先队列-stl
- 黑苹果驱动
- 100行php代码实现加密端口转发
- 数据录入达人(数据录入达人官方下
- (转)30道面试题
- windows10 qt5 mingw32编译cryptopp563
- docker – 你应该知道的10件事
- 阿里云服务器被挖矿minerd入侵的解决办法
- 【转】利用Pspice分析放大器环路的稳定性
- mysql如何字段引用和防止出现数据库关键字
- 工厂方法模式
- 开方运算(求根)-- 中值定理
- hashCode与equals的区别与联系
- MyBatis小demo
- Android自定义ListView实现下拉刷新
- 鸿洋大神的intentService
- 异步任务之AsyncTask实现<一>
- ACM 训练计划