20140501 Anindilyakwa 题解The Great Team 题解

2024-06-15 19:58

本文主要是介绍20140501 Anindilyakwa 题解The Great Team 题解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 练习结束之后才发现 这两条其实挺水的。。能力还是太弱  水题都刷不动了的节奏么  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 1x 2 and  x 3 (1 ≤  x 1x 2x 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 llusing 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;
}




这篇关于20140501 Anindilyakwa 题解The Great Team 题解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1064426

相关文章

C++ | Leetcode C++题解之第393题UTF-8编码验证

题目: 题解: class Solution {public:static const int MASK1 = 1 << 7;static const int MASK2 = (1 << 7) + (1 << 6);bool isValid(int num) {return (num & MASK2) == MASK1;}int getBytes(int num) {if ((num &

C语言 | Leetcode C语言题解之第393题UTF-8编码验证

题目: 题解: static const int MASK1 = 1 << 7;static const int MASK2 = (1 << 7) + (1 << 6);bool isValid(int num) {return (num & MASK2) == MASK1;}int getBytes(int num) {if ((num & MASK1) == 0) {return

C - Word Ladder题解

C - Word Ladder 题解 解题思路: 先输入两个字符串S 和t 然后在S和T中寻找有多少个字符不同的个数(也就是需要变换多少次) 开始替换时: tips: 字符串下标以0开始 我们定义两个变量a和b,用于记录当前遍历到的字符 首先是判断:如果这时a已经==b了,那么就跳过,不用管; 如果a大于b的话:那么我们就让s中的第i项替换成b,接着就直接输出S就行了。 这样

【秋招笔试】9.07米哈游秋招改编题-三语言题解

🍭 大家好这里是 春秋招笔试突围,一起备战大厂笔试 💻 ACM金牌团队🏅️ | 多次AK大厂笔试 | 大厂实习经历 ✨ 本系列打算持续跟新 春秋招笔试题 👏 感谢大家的订阅➕ 和 喜欢💗 和 手里的小花花🌸 ✨ 笔试合集传送们 -> 🧷春秋招笔试合集 🍒 本专栏已收集 100+ 套笔试题,笔试真题 会在第一时间跟新 🍄 题面描述等均已改编,如果和你笔试题看到的题面描述

LeetCode 第414场周赛个人题解

目录 Q1. 将日期转换为二进制表示 原题链接 思路分析 AC代码 Q2. 范围内整数的最大得分 原题链接 思路分析 AC代码 Q3. 到达数组末尾的最大得分 原题链接 思路分析 AC代码 Q4. 吃掉所有兵需要的最多移动次数 原题链接 思路分析 AC代码 Q1. 将日期转换为二进制表示 原题链接 Q1. 将日期转换为二进制表示 思路分析

牛客小白月赛100部分题解

比赛地址:牛客小白月赛100_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ A.ACM中的A题 #include<bits/stdc++.h>using namespace std;#define ll long long#define ull = unsigned long longvoid solve() {ll a,b,c;cin>>a>>b>

P2858 [USACO06FEB] Treats for the Cows G/S 题解

P2858 题意 给一个数组。每天把最左或者最右的东西卖掉,第 i i i个东西,第 d a y day day天卖出的价格是 a [ i ] ∗ d a y a[i]*day a[i]∗day。 记忆化搜索 void dfs(int l,int r,int day,ll sum){if(v[l][r]>=sum)return;v[l][r]=sum;if(l>r)//这就是dp答案{

【C++题解】1272. 郭远摘苹果

欢迎关注本专栏《C++从零基础到信奥赛入门级(CSP-J)》 问题:1272. 郭远摘苹果 类型:二维数组 题目描述: 郭远有一天走到了一片苹果林,里面每颗树上都结有不同数目的苹果,郭远身上只能拿同一棵树上的苹果,他每到一棵果树前都会把自己身上的苹果扔掉并摘下他所在树上的苹果并带走(假设郭远会走过每一棵苹果树),问在郭远摘苹果的整个过程中,他身上携带的最多苹果数与最小苹果数的差是多少?

【最新华为OD机试E卷-支持在线评测】机器人活动区域(100分)多语言题解-(Python/C/JavaScript/Java/Cpp)

🍭 大家好这里是春秋招笔试突围 ,一枚热爱算法的程序员 ✨ 本系列打算持续跟新华为OD-E/D卷的三语言AC题解 💻 ACM金牌🏅️团队| 多次AK大厂笔试 | 编程一对一辅导 👏 感谢大家的订阅➕ 和 喜欢💗 🍿 最新华为OD机试D卷目录,全、新、准,题目覆盖率达 95% 以上,支持题目在线评测,专栏文章质量平均 94 分 最新华为OD机试目录: https://blog.

2023 CCPC(秦皇岛)现场(第二届环球杯.第 2 阶段:秦皇岛)部分题解

所有题目链接:Dashboard - The 2023 CCPC (Qinhuangdao) Onsite (The 2nd Universal Cup. Stage 9: Qinhuangdao) - Codeforces 中文题面: contest-37054-zh.pdf (codeforces.com) G. Path 链接: Problem - G - Codeforces