/images/avatar.png

^_^

hduoj1796

How many integers can you find

Problem Description

Now you get a number N, and a M-integers set, you should find out how many integers which are small than N, that they can divided exactly by any integers in the set. For example, N=12, and M-integer set is {2,3}, so there is another set {2,3,4,6,8,9,10}, all the integers of the set can be divided exactly by 2 or 3. As a result, you just output the number 7.

牛客练习赛61(部分)

A . 打怪

题解

模拟

ac代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<bits/stdc++.h>
using namespace std;
int main(){
	//freopen("in.txt","r",stdin);
	int t,a,b,c,d;
	cin>>t;
	while(t--){
		cin>>a>>b>>c>>d;
		if(b>=c || d<=0) cout<<-1<<endl;
		else{
			int num=0;
			int cx=c;
			bool me=true;
			while(a>0){
				if(me){
					cx-=b; me^=1;
				}
				else{
					a-=d;me^=1;
				}
				if(cx<=0) {
					cx=c;num++;me=true;
				}
			}
			if(num>10000) cout<<-1<<endl;else cout<<num<<endl;
		}
	}
	return 0;
}

B . 吃水果

题解

贪心

NC13611

题目描述

shy有一颗树,树有n个结点。有k种不同颜色的染料给树染色。一个染色方案是合法的,当且仅当对于所有相同颜色的点对(x,y),x到y的路径上的所有点的颜色都要与x和y相同。请统计方案数。

abc161

A - ABC Swap

题意

给三个数a,b,c,交换ab的值,交换ac的值,输出

题解

模拟

ac代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}

B - Popular Vote

题意

有n件商品,每种商品有一价格,给一数m

浮点数加减法

#0 0操作数检查

如果有一个数为0,则可以直接得出结果

#1 用补码表示阶码,尾数

阶码的符号位为两位

尾数的个位为符号位

#2 对阶

小阶向大阶对齐(看原码),被对阶的数尾数右移阶差个

Codeforces Round #630 (Div. 2) A~E

A. Exercising Walk

题意

给一坐标范围,初始位置,和左右上下移动的步数,问是否会出界

题解

加各种条件判断即可

ac代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include<bits/stdc++.h>
using namespace std;
int t;
int a,b,c,d,x,y,x1,y1,x2,y2;
bool ok;
int main(){
	//freopen("input.txt","r",stdin);
	cin>>t;
	while(t--){
		ok=true;
		cin>>a>>b>>c>>d>>x>>y>>x1>>y1>>x2>>y2;
		if( (a-b>=0 and x-x1<a-b) or (b-a>0 and x2-x<b-a) or (c-d>0 and y-y1<c-d) or (d-c>0 and y2-y<d-c) or 
		(a==b and a!=0 and x1==x and x2==x) or (c==d and c!=0 and y1==y and y2==y) )
		ok = false;
		if(ok) puts("yes"); else puts("no");
	}
	return 0;
}

B. Composite Coloring

题意

给n个合数上色,要求相同颜色的数字必须不互质,求最小着色数和着色方案

abc160

A - Coffee

题意

判断一个长度为6的字符串,第3位和第4位是否相等,第5位和第6位是否相等

题解

模拟

ac代码

1
2
3
4
5
6
7
8
9
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[2]==s[3] and s[4]==s[5]) cout<<"Yes";
	else cout<<"No";
	return 0;
}

B - Golden Coins

题意

高桥有许多钱,可以兑换成各种硬币,每获得一枚500円的硬币,就能获得1000

星际牛仔

《星际牛仔》(カウボーイビバップ;Cowboy Bebop),是日本SUNRISE动画

公司制作的原创电视动画,于1998年10月23日-1999年4月23日在东京电视台和

Codeforces Round #629 (Div. 3)

A. Divisibility Problem

题意

求一个数加上多少能被另一个数整除

题解

如果b|(a+k)

则k=b-a%b注意k=0特判

ac代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#include<bits/stdc++.h>
using namespace std;
int t,a,b;
int main(){
	//freopen("input.txt","r",stdin);
	cin>>t;
	while(t--){
		cin>>a>>b;
		cout<<(b-(a%b)==b?0:b-(a%b))<<endl;
	}
	return 0;
}

B. K-th Beautiful String

题意

一个长度为n的字符串,由n-2个a组成和2个b组成