练习结束之后才发现 这两条其实挺水的。。能力还是太弱 水题都刷不动了的节奏么 555555555555
不能老是这么做这些题了 要补知识啊补知识
Description
The language of Australian aborigines anindilyakwa has no numerals. No anindilyakwa can say: “I've hooked eight fishes”. Instead, he says: “I've hooked as many fishes as many stones are in this pile”.
Professor Brian Butterworth found a meadow with three piles of stones. He decided to determine whether aborigines can count. Professor asked one of the aborigines to point at two piles with the minimal difference of numbers of stones in them and tell what this difference is. The aborigine pointed correctly! He was unable to express the difference with words, so he went to a shore and returned with a pile of the corresponding number of stones.
Professor decided to continue his experiments with other aborigines, until one of them points at two piles with equal number of stones. All piles that aborigines bring from the shore are left at the meadow. So, the second aborigine will have to deal with one more pile, the one brought by the first aborigine.
Input
The only input line contains space-separated pairwise distinct integers
x
1,
x
2 and
x
3
(1 ≤
x
1,
x
2,
x
3 ≤ 10
18)
, which are the numbers of stones in piles that were lying on the meadow at the moment professor Butterworth asked the first aborigine.
Output
Output the number of aborigines that will have to answer a stupid question by professor.
Sample Input
input | output |
---|---|
11 5 9 | 3 |
Hint
The first aborigine will point at piles of 11 and 9 stones and will bring a pile of two stones. The second aborigine will point at the same piles and will bring another pile of two stones. The third aborigine will point at two piles of two stones, and the experiments will be over.
代码:
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
#include <iostream>
#include <cstdio>
#include <algorithm>
//#define long long ll
using namespace std;
const int maxn=100010;
long long a[maxn];
long long b[maxn];
//int main()
//{
// long long x,y,z;
// while(cin>>x>>y>>z)
// {
// a[0]=x;a[1]=y;a[2]=z;
// long long len=3;
// sort(a,a+len);
cout<<a[0]<<endl;
// b[0]=a[2]-a[1];
// b[1]=a[2]-a[0];
// b[2]=a[1]-a[0];
// sort(b,b+len);
cout<<b[0]<<endl;
// while(b[0]!=0)
// {
// if(b[0]<a[0])
// {
// a[len]=b[0];
// b[len]=min(b[0],a[0]-b[0]);
// len++;
// sort(a,a+len);
// sort(b,b+len);
// }
// else
// {
// a[len]=b[0];
// int c=b[0]-a[0];
// int d=a[1]-b[0];
// int e=min(c,d);
// b[len]=e;
// //cout<<b[len]<<endl;
// len++;
// sort(a,a+len);
// sort(b,b+len);
// }
// }
// len++;
// cout<<len-2<<endl;
// }
// return 0;
//}
long long Abs(long long a)
{
return a>0?a:-a;
}
int main()
{
while(cin>>a[0]>>a[1]>>a[2])
{
long long min1=min(Abs(a[0]-a[1]),Abs(a[0]-a[2]));
long long min2=min(Abs(a[2]-a[1]),min1);
int k=3;
a[k]=min2;
while(min2)
{
for(int i=0;i<k;i++)
min2=min(Abs(a[k]-a[i]),min2);
if(min2)
a[++k]=min2;
}
cout<<k-1<<endl;
}
return 0;
}
Description
When a few students of the Ural State University finished their sport career, the university encountered a lot of problems in team composition. Veterans of sports programming decided to play their role and create the most successful team in the history of the Ural SU.
Veterans assumed that success of a team strongly depends on the number of friends in the ACM community the members of this team have. After more discussions they developed the
criterion of success: all three members of the team should have the same number of friends.
Unfortunately, the veterans failed to compose a team, as it turned out that there were no three programmers in the Ural SU that together satisfied this criterion.
You should use this information to determine which students are friends of each other.
Input
The first line contains a single integer
n
(3 ≤
n ≤ 200)
, which is the number of students in the Ural SU participating in programming contests.
Output
If the veterans' calculations are correct, the first line should contain an integer
k, which is the number of pairs of students that are friends of each other. The following
k lines should contain these pairs. Students should be numbered 1 through
n. If a problem has multiple correct answers, output any of them.
If the veterans are wrong and the problem has no solution, output a single line containing a number −1.
Sample Input
input | output |
---|---|
4 | 2 1 3 3 4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
if(n&1) n--;
cout<<n*(n+2)/8<<endl;
for(int i=1;i<=n/2;i++)
for(int j=n/2+i;j<=n;j++)
cout<<i<<" "<<j<<endl;
}
return 0;
}