CCPC-Wannafly Camp Day7 总结

CCPC-Wannafly Camp Day7 总结

7-8 7H. Game

These figures have each 1 to a n. Several rounds you play with these numbers. For each round, if the number of digits the rest of the more than one, then two and so the probability of randomly selecting the remaining numbers deleted. If these two prime numbers, have a point. Repeat until no numbers can be deleted. Finally, expectations etc., how may I ask?

Input format
line an integer n (1≤n≤5000).

Output format
output a number of the most simple
b A represents answer.


Sample input
2

4

Sample Output
1/1

5/3

Thinking

Since the beginning of the direct output 0/0 0, WA for a long time ......

#include<iostream>
#include<vector>
#define ll long long
using namespace std;
ll gcd(ll a, ll b)
{
	if(a%b==0)
		return b;
	else 
		return gcd(b, a%b);
}
int main()
{
	ll n, x=0, fenmu, fenzi;
	cin>>n;
	if(n==1)
	{
		cout<<"0/1"<<endl;
		return 0; 
	}
	for(ll i=1; i<=n; i++)
	{
		for(ll j=i+1; j<=n; j++)
		{
			if(gcd(i, j)==1)
			{
				x++;
			}
		}
	}
	fenzi=x*(n/2)*2;
	fenmu=n*(n-1);
	ll mod=gcd(fenmu, fenzi);
	fenmu/=mod;
	fenzi/=mod;
	cout<<fenzi<<"/"<<fenmu<<endl;
}

7-11 7K. Practice

There is a double game, two players control two characters, the ability of the two characters can be represented by v1, v2, the initial capacity of the two are zero.

Units of the game is the day, every day two men were lifting will a1, a2 ability value, in addition, the ability to get a point every day, let a1 + = 1 or a2 + = 1.

They wait until practice long enough, you can play the boss with customs.

Small wah wah by checking the Raiders, the ability to find the last two combinations of values ​​as long as v1≥b1 and v2≥b2, can cross the border.

Since there are many ways clearance, there may be many combinations of groups b1, b2, and as long as any of clearance can be set.

Now small wah wah want to know the shortest days can clearance.

Input format
The first line number 2, represents a1, a2 (0≤a1, a2 < 100000).

Enter a next line number n (1≤n≤1000).

The following n rows, each row number 2, represents a group can clearance B1, B2 (0 <B1, B2 <10
. 9
).

Output format of
a minimum clearance number indicates the number of days.

Input Sample
0 0
. 1
. 1 2

1 1
2
5 7
6 6

Sample Output
2

3

Thinking

Look at the code

#include<iostream>
using namespace std;
struct all
{
	long long b1,b2;
};
all a[1005],b[1005];
long long chu(long long aa,long long bb)
{
	if(aa<=0) return 0;
	else
	{
		if(bb==0) return aa+1000000000;
		else
		{
			if(aa%bb==0) return aa/bb;
			else return aa/bb+1;
		}
	}
}
int main()
{
	long long a1,a2,v1=0,v2=0;
	cin>>a1>>a2;
	long long n;
	cin>>n;
	long long minx=1000000000009;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i].b1>>a[i].b2;
	}
	
	long long minas=1000000000009;
	long long we=a1,qe=a2;
	for(long long j=1; j<=n; j++)
	{
		v1=0;v2=0;
		a1=we;
		a2=qe;
		for(long long i=1;;i++)
		{
			if(chu(a[j].b2-v2,a2)>=chu(a[j].b1-v1,a1))
			{
				a2++;
			}
			else a1++;
			v1+=a1;
			v2+=a2;
			if(v1>=a[j].b1&&v2>=a[j].b2)
			{
				minas=min(i,minas);
				break;
			}
		}
	}
	cout<<minas<<endl;
	return 0;
} 

Finally over ...... commuting from work ......
happy

Published 28 original articles · won praise 3 · Views 1734

Guess you like

Origin blog.csdn.net/ArwenNi/article/details/104080478