codeforces——962
http://codeforces.com/problemset/problem/962/A
当前缀最短是多长时,前缀和为全串和的一半以上
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <cmath>
using namespace std;const int kInt_Positive_Infinity_ = 0x3f3f3f3f;
const int kInt_Negative_Infinity_ = 0xcfcfcfcf;#define kPI kInt_Positive_Infinity_
#define kNI kInt_Negative_Infinity_
#define LL long long
#define ULL unsigned long long
double sum;
template <typename cinType>
void getArr ( cinType *a, int n ) {for ( int i = 0; i < n; i++ ) {cin >> a[i];sum += a[i];}
}
template <typename coutType>
void putArr ( coutType *a, int n ) {for ( int i = 0; i < n; i++ )if ( i == n - 1 ) cout << a[i] << endl;else cout << a[i] << ' ';
}
template <typename reSetType>
void reSet ( reSetType *a, int n, reSetType val ) {for ( int i = 0; i < n; i++ )a[i] = val;
}int main() {std::ios::sync_with_stdio ( false );cin.tie ( 0 );int n, in[200002];while ( cin >> n ) {sum = 0;getArr<int> ( in, n );sum = sum / 2.0;for ( int i = 0; i < n; i++ ) {sum -= in[i];if ( sum <= 0.01 ) {cout << i + 1 << endl;break;}}}return 0;
}
http://codeforces.com/problemset/problem/962/B
有ab两种学生,两种学生不能相邻而坐,问最多能坐几个学生下去
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <cmath>
using namespace std;const int kInt_Positive_Infinity_ = 0x3f3f3f3f;
const int kInt_Negative_Infinity_ = 0xcfcfcfcf;#define kPI kInt_Positive_Infinity_
#define kNI kInt_Negative_Infinity_
#define LL long long
#define ULL unsigned long longchar in[200004];
int main() {int n, m1, m2;while ( ~scanf ( "%d%d%d", &n, &m1, &m2 ) ) {scanf ( "%s", &in );int x1 = 0, x2 = 0;for ( int i = 0; i < strlen ( in ); i++ )if ( in[i] == '.' ) {int sum = 1;while ( in[i + 1] == '.' )sum++, i++;x1 += sum / 2;x2 += sum % 2;}cout << min ( x1, m1 ) + min ( x1, m2 ) + min ( x2, ( x1 < m1 ? m1 - x1 : 0 ) + ( x1 < m2 ? m2 - x1 : 0 ) ) << endl;}return 0;
}
http://codeforces.com/problemset/problem/962/C
在所给数字中拆出一个平方数,且该平方数长度最长,若没有,输出-1。(数字无前导0)
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <cmath>
using namespace std;const int kInt_Positive_Infinity_ = 0x3f3f3f3f;
const int kInt_Negative_Infinity_ = 0xcfcfcfcf;#define kIPI kInt_Positive_Infinity_
#define kINI kInt_Negative_Infinity_
#define LL long long
#define ULL unsigned long longchar in[20];
int main() {while ( ~scanf ( "%s", &in ) ) {int len = pow ( 2, strlen ( in ) ), ans = kIPI;for ( int i = 1; i < len; i++ ) {int temp = i, k = 0, t = 0;char str[20];for ( int j = 0; j < strlen ( in ); j++, temp = temp >> 1 )if ( temp & 1 && ( k == 0 ? ( in[j] != '0' ) : true ) ) str[k++] = in[j];else t++;str[k++] = 0;sscanf ( str, "%d", &temp );if ( ( int ) sqrt ( temp ) * ( int ) sqrt ( temp ) == temp && temp ) ans = min ( t, ans );}if ( ans == kIPI ) cout << "-1" << endl;else cout << ans << endl;}return 0;
}
http://codeforces.com/problemset/problem/962/D
数组中若有两个相同的值,删除左边的值并将右边的值乘2,输出最后结果。
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <cmath>
using namespace std;const int kInt_Positive_Infinity_ = 0x3f3f3f3f;
const int kInt_Negative_Infinity_ = 0xcfcfcfcf;#define kIPI kInt_Positive_Infinity_
#define kINI kInt_Negative_Infinity_
#define LL long long
#define ULL unsigned long longchar in[20];
int main() {std::ios::sync_with_stdio ( false );cin.tie ( 0 );LL n, in[150006];while ( cin >> n ) {for ( int i = 1; i <= n; i++ )cin >> in[i];map<LL, int>ma;int sum = n;for ( int i = 1; i <= n; )if ( ma[in[i]] == 0 ) {ma[in[i]] = i;i++;} else {in[ma[in[i]]] = 0;ma[in[i]] = 0;in[i] *= 2;sum--;}cout << sum << endl;for ( int i = 1; i <= n; i++ )if ( in[i] != 0 ) cout << in[i] << ' ';cout << endl;}return 0;
}
codeforces——962相关推荐
- A、B、C、D、Educational Codeforces Round 42 (Rated for Div. 2)
Educational Codeforces Round 42 (Rated for Div. 2) http://codeforces.com/contest/962 A:Equator 这里需要 ...
- codeforces 962C Make a Square
题目链接:http://codeforces.com/contest/962/problem/C 题意:给你一个数字n (n<=2e9)没有前导0.现在需要你删除一些数字,也可以不删除,使得剩下 ...
- CodeForces 962C - Make a Square
题目链接:http://codeforces.com/contest/962/problem/C 题意:给你一个数字n (n<=2e9)没有前导0.现在需要你删除一些数字,也可以不删除,使得剩下 ...
- CodeForces 375D Tree and Queries
传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...
- 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)
题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...
- 【codeforces 812C】Sagheer and Nubian Market
[题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...
- CodeForces 获得数据
针对程序的输出可以看见 CodeForces :当输入.输出超过一定字符,会隐藏内容 所以:分若干个程序进行输入数据的获取 1. 1 for (i=1;i<=q;i++) 2 { 3 scanf ...
- codeforces水题100道 第二十七题 Codeforces Round #172 (Div. 2) A. Word Capitalization (strings)...
题目链接:http://www.codeforces.com/problemset/problem/281/A 题意:将一个英文字母的首字母变成大写,然后输出. C++代码: #include < ...
- CodeForces 595A
题目链接: http://codeforces.com/problemset/problem/595/A 题意: 一栋楼,有n层,每层有m户,每户有2个窗户,问这栋楼还有多少户没有睡觉(只要一个窗户灯 ...
- codeforces A. Jeff and Digits 解题报告
题目链接:http://codeforces.com/problemset/problem/352/A 题目意思:给定一个只有0或5组成的序列,你要重新编排这个序列(当然你可以不取尽这些数字),使得这 ...
最新文章
- Windows Server 2003 : 服务器群集
- 1070 Mooncake
- C# 设计开发模式 -观察者模式
- Spring Boot - 自动配置实现原理
- 【数据竞赛】kaggle竞赛宝典-多分类相关指标优化​
- android 如何终止线程
- 洛谷 - P2324 - 骑士精神 - A*搜索
- ISA server的常见身份验证方式
- Nifty JUnit:在方法和类级别上使用规则
- 加载慢_解决游戏加载慢不必大刀阔斧升改,教你一个简单有效的方法
- Python风格总结:数据类型
- 人民大学的《统计学》
- Bootstrap 按钮
- ArcGIS Maritime Server 开发教程(七)Maritime Server 正确的开发模式
- 编译linux内核成vmlinuz,Linux内核vmlinuz文件认识
- 电力猫服务器的网页,电力猫方案完美解决家庭网络布局
- ipad 邮箱服务器端口,ipad邮箱设置,牛排,YAHOO邮箱(后缀为yahoo
- hao123.com 360浏览器等主页被劫持的解决方法
- 基于Web2.0的异构数字资源检索系统研究与开发
- 中文分词与关键词提取概述