Summer training #4
D:找到两个数 一个是另一个的整数倍(1也算)
因为N是600000 调和级数为ln(n+1) 算一下 可以直接爆
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1.0e-8
#define PI acos(-1.0)
#define INF 3000000000
#define MOD 1000000009
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
bool cmp(int x,int y){return x>y;}
int where[];
int visit[];
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int n,k;
cin >> n >> k;
int ans1=,ans2=;
int t;
for(int i=;i<=k;i++)
{
scanf("%d",&t);
if(visit[t]!=) //==1
{
ans1=where[t];
ans2=i;
break;
}
visit[t]++;
where[t]=i;
}
if(ans1!=&&ans2!=)
{
printf("%d %d\n",ans1,ans2);
return ;
}
for(int i=;i<=n;i++)
for(int j=*i;j<=n;j+=i)
{
if(visit[i]!=&&visit[j]!=)
{
ans1=where[i];
ans2=where[j];
break;
}
}
if(ans1!=&&ans2!=)
{
printf("%d %d\n",ans1,ans2);
return ;
}
printf("0 0\n");
return ;
}
E:两个板之间的数之和是K的倍数?? 反正这么做过了
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1.0e-8
#define PI acos(-1.0)
#define INF 3000000000
#define MOD 1000000009
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
bool cmp(int x,int y){return x>y;}
char a[];
//(a1+an)*n/2;
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int n,k;
cin >> n;
scanf("%s",a+);
//printf("%s\n",a+1);
int num=;
int len=strlen(a+);
//cout <<len<<endl;
int first=,last=;
int pop=;
for(int i=;i<=len&&pop!=;i++)
{
if(a[i]=='')
{
//TS;
for(int j=i;j<len;j+=n)
{
//cout << j<<endl;
if(a[j+]=='')
{
first=i;
last=j+;
pop=;
break;
}
}
}
}
if(first!=&&last!=)
{
printf("%d %d",first,last);
return ;
}
printf("0 0\n");
return ;
}
G:水
H:2*3的砖铺 N*M的地板 以前CF好像做过 直接判min(n,m)>=2&&max(n,m)>=3 然后n*m%6==0
证明的话 引用别人的:
乘积是6的倍数那就说明有因子2和3:
1)一边是2的倍数恰好另一边是3的倍数,这种情况下显然可行;
2)一边是6的倍数另一边不是2也不是3的倍数,那另一边肯定是奇数,为1的时候不行,设边为N=2a+1=2(a-1)+3,那前面就以2x3的形式放最后一个以3x2的形式放,由于一边为6的倍数那么就是一定可以放得下的
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1.0e-8
#define PI acos(-1.0)
#define INF 3000000000
#define MOD 1000000009
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int k;
cin >> k;
while(k--)
{
ll n,m;
cin >> n >> m;
ll sum=n*m;
if(min(n,m)<||max(n,m)<)
{
cout<<"No"<<endl;
continue;
}
if(sum%==)
cout <<"Yes"<<endl;
else
cout <<"No"<<endl;
}
return ;
}
I:阅读理解 把最长的R B先连起来
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1.0e-8
#define PI acos(-1.0)
#define INF 3000000000
#define MOD 1000000009
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
int red[],blue[];
bool cmp(int x,int y){return x>y;}
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int n;
while(scanf("%d",&n)==)
{
mem(red,);
mem(blue,);
int pop=;
int pop1=;
int number=;
int ans=;
char ch;
int j;
for(int i=;i<=n;i++)
{
cin >> j>>ch;
if(ch=='R')
{
red[++pop]=j;
}
else
{
blue[++pop1]=j;
}
}
sort(red+,red+pop+,cmp);
sort(blue+,blue+pop1+,cmp);
for(int i=;i<=min(pop,pop1);i++)
{
ans+=red[i]+blue[i]-;
}
cout <<ans<<endl;
}
return ;
}
J:按条件读取字符 组成词组 输出
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1.0e-8
#define PI acos(-1.0)
#define INF 3000000000
#define MOD 1000000009
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
typedef long long ll;
//stack<string> a;
int pop=;
map<string,int> mp;
string strans;
int ans=;
char c[];
//(a1+an)*n/2;
void print()
{
for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
{
if(it->second>ans)
{
strans=it->first;
ans=it->second;
}
}
cout << strans<<":"<<ans<<endl;
}
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
while(gets(c))
{
int len=strlen(c);
if(len==&&c[]=='#')
{
print();
mp.clear();
strans="";
ans=;
continue;
}
else
{
for(int i=;i<len;i++)
{
string start="";
if(c[i]>='a'&&c[i]<='z')
{
int cur=i;
while(c[cur]>='a'&&c[cur]<='z')
{
start+=c[cur];
cur++;
}
i=cur;
if(c[cur]==','||c[cur]=='\0')
continue;
start+=' ';
while(c[cur]==' ')
cur++;
while(c[cur]>='a'&&c[cur]<='z')
{
start+=c[cur];
cur++;
}
//cout <<"start="<<start<<" ";
//cout <<endl;
mp[start]++;
}
}
}
}
return ;
}
Summer training #4的更多相关文章
- hdu 4946 2014 Multi-University Training Contest 8
Area of Mushroom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 2016 Multi-University Training Contests
2016 Multi-University Training Contest 1 2016 Multi-University Training Contest 2 2016 Multi-Univers ...
- 2016 Multi-University Training Contest 2 D. Differencia
Differencia Time Limit: 10000/10000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- 2016 Multi-University Training Contest 1 G. Rigid Frameworks
Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- The Solution of UESTC 2016 Summer Training #1 Div.2 Problem C
Link http://acm.hust.edu.cn/vjudge/contest/121539#problem/C Description standard input/output After ...
- 2012 Multi-University Training Contest 9 / hdu4389
2012 Multi-University Training Contest 9 / hdu4389 打巨表,实为数位dp 还不太懂 先这样放着.. 对于打表,当然我们不能直接打,这里有技巧.我们可以 ...
- 2014 Multi-University Training Contest 9#11
2014 Multi-University Training Contest 9#11 Killing MonstersTime Limit: 2000/1000 MS (Java/Others) ...
- 2014 Multi-University Training Contest 9#6
2014 Multi-University Training Contest 9#6 Fast Matrix CalculationTime Limit: 2000/1000 MS (Java/Oth ...
- 2016 Multi-University Training Contest 1
8/11 2016 Multi-University Training Contest 1 官方题解 老年选手历险记 最小生成树+线性期望 A Abandoned country(BH) 题意: 1. ...
随机推荐
- Unity Shader概述
一.概述 在Unity中需要配合使用材质和Unity Shader才能达到需要的效果.常见的流程:(1)创建一个材质:(2)创建一个Unity Shader,并把它赋给创建的材质:(3)把材质赋给要渲 ...
- 安装neutron
在控制节点上执行 controllerHost='controller' MYSQL_PASSWD='m4r!adbOP' RABBIT_PASSWD='0penstackRMQ' NOVA_PASS ...
- Leetcode之动态规划(DP)专题-198. 打家劫舍(House Robber)
Leetcode之动态规划(DP)专题-198. 打家劫舍(House Robber) 你是一个专业的小偷,计划偷窃沿街的房屋.每间房内都藏有一定的现金,影响你偷窃的唯一制约因素就是相邻的房屋装有相互 ...
- Laravel注册登陆认证API
注册接口 路由api.php:Route::post('register', 'Auth\RegisterController@register'); 控制器 http//controllers/au ...
- Autoit安装及启动
1.Autoit下载: 官网下载地址:https://www.autoitscript.com/site/autoit/downloads/ 提供百度网盘下载:https://pan.baidu.co ...
- 自学电脑游戏第四天(Swing)
继续之前的 3.组合框(JComboBox) 例题:利用JComboBox设计一个选择城市的程序. import java.awt.*; import javax.swing.*; public cl ...
- [转帖]瀚高数据库创建uuid的方法
使用syssso登录,并执行下列语句 highgo=> select set_secure_level('off'); set_secure_level -------------------- ...
- easyswoole报错:failed: Error during WebSocket handshake: Unexpected response code: 200
WebSocket connection to 'ws://www.xxxx.com/xxx/xx' failed: Error during WebSocket handshake: Unexpec ...
- 【求教 探讨】python tkinter的messagebox
最近有一个要求,用python的tkinter制作一个messagebox,传入3个参数: title text timeout.用户可以点击“确定” 关闭窗口: 或者 等待几秒(timeout) ...
- 怎样在 Vue 里面使用自定义事件将子组件的数据传回给父组件?
首先, Vue 里面的组件之间的数据流动是 单向 的, 数据可以从父组件传递给子组件, 但不能从子组件传递给父组件, 因为组件和组件之间是 隔离 的. 就像两个嵌套的 黑盒子 . 能通过 props ...