2018ccpc_hn
A. Easy h-index
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = *1e5 + ;
using namespace std;
const int MOD = 1e9+;
typedef long long ll; int a[maxn]; int main(){
Faster;
int n;
while(cin >> n){
for(int i = ;i <= n;i++){
cin >> a[i];
} int sum = ;
int h = n+;
while(sum < h){
sum += a[--h];
}
cout << h << endl;
}
return ;
}
B. Higher h-index
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = *1e5 + ;
using namespace std;
const int MOD = 1e9+;
typedef long long ll; int a[maxn]; int main(){
Faster;
int n, a;
while(cin >> n >> a){
if(n < a)
cout << n << endl;
else{
int h = a + (n-a)/;
cout << h << endl;
}
}
return ;
}
F. Sorting
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = 1e3+;
using namespace std;
const int MOD = 1e9+;
typedef long long ll; struct node
{
ll a,b,c;
int id;
}t[maxn]; bool cmp(node x, node y){
ll xx = x.a*y.c + x.b*y.c;
ll yy = y.a*x.c + y.b*x.c;
if(xx == yy)
return x.id < y.id;
return xx < yy;
} int main(){
Faster;
int n;
while(cin >> n){
for(int i = ;i < n;i++){
cin >> t[i].a >> t[i].b >> t[i].c;
t[i].id = i+;
}
sort(t,t+n,cmp);
for(int i = ;i < n;i++){
if(i == )
cout << t[i].id;
else
cout << " " << t[i].id;
}
cout << endl;
}
return ;
}
G. String Transformation
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = 1e5 + ;
using namespace std;
const int MOD = 1e9+;
typedef long long ll; int main(){
Faster;
string s;
string t;
while(cin >> s >> t){
int sc, tc;
sc = tc = ;
for(char x:s){
if(x == 'c'){
sc++;
}
}
for(char x:t){
if(x == 'c'){
tc++;
}
}
if(sc != tc){
cout << "No" << endl;
continue;
}
int i, j, sa, sb, ta, tb;
i = j = sa = sb = ta = tb = ;
bool ok = true;
s += "c";
t += "c";
while(i < s.size() && j < t.size()){
while(s[i] != 'c' && i < s.size()){
if(s[i] == 'a')
sa++;
if(s[i] == 'b')
sb++;
i++;
}
while(t[j] != 'c' && j < t.size()){
if(t[j] == 'a')
ta++;
if(t[j] == 'b')
tb++;
j++;
}
if( sa% != ta% || sb% != tb%){
ok = false;
break;
}
if(s[i] == 'c'){
sa = sb = ;
i++;
}
if(t[j] == 'c'){
ta = tb = ;
j++;
}
}
if(ok)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return ;
}
K. 2018
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = 1e4 + ;
using namespace std;
const int MOD = 1e9+;
typedef long long ll; int main(){
Faster;
ll a, b, c, d;
while(cin >> a >> b >> c >> d){
ll sum = ;
ll x = (b/ - (a-)/);
ll y = (d/ - (c-)/);
sum += x*(d-c+)+y*(b-a+)-x*y; //减去重复的部分 sum += (b/ - (a-)/ - x)*(d/ - (c-)/ - y);
sum += (d/ - (c-)/ - y)*(b/ - (a-)/ - x);
cout << sum << endl;
} return ;
}
2018ccpc_hn的更多相关文章
- 2018湘潭邀请赛 AFK题解 其他待补...
A.HDU6276:Easy h-index Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
随机推荐
- java验证码问题
AuthImageServlet.java package com.util.servlet; import java.awt.Color;import java.awt.Font;import ja ...
- sample code java pom.xml
pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="htt ...
- CentOS-7-64bit 下为firefox安装flashplayer
最近更新了Centos 7 还是有一些不习惯的 给ff安flashplayer插件时,按centos 6.x的方法时都无法成功,后来find了一下,才知道firefox还有一个64bit的文件夹: 解 ...
- ICE协议下NAT穿越的实现(STUN&TURN)
正文: 一. 首先来简单讲讲什么是NAT? 原来这是因为IPV4引起的,我们上网很可能会处在一个NAT设备(无线路由器之类)之后.NAT设备会在IP封包通过设备时修改源/目的IP地址. 对于家用路由器 ...
- apeche配置虚拟主机
一.开启虚拟主机: 在apache的配置文件httpd.conf中将Include conf/extra/httpd-vhosts.conf这行打开. 二.配置虚拟主机: 在extra/httpd-v ...
- C++中对类的提前引用声明注意事项
//或许,友元是VC++6.0心里永远的痛,对于这个BUG我一直很介意.//注:这个程序在VC++6.0里是行不通的,在VS2008里是可以的.#include <iostream> #i ...
- HDU1852 Beijing 2008(快速幂+特殊公式)
As we all know, the next Olympic Games will be held in Beijing in 2008. So the year 2008 seems a lit ...
- js 判断滚动条是不是在浏览器底部
http://jingyan.baidu.com/album/86f4a73e91da7837d65269d5.html?picindex=2
- C++类对象之间的类型转换和重载
类对象和其他类型对象的转换 转换场合有: 赋值转换 表达式中的转换 显式转换 函数调用, 传递参数时的转换 转换方向有: 由定义类向其他类型的转换 由其他类型向定义类的转换 #include < ...
- python虚拟环境管理包virtualenvwrapper
1.打开cmd 2.安装virtualenvwrapper pip install virtualenvwrapper-win 3.配置虚拟环境的位置 新建系统变量默认在c盘 4.新建虚拟环境 mkv ...