2019长安大学ACM校赛网络同步赛 - cs加油

2019长安大学ACM校赛网络同步赛
A- Seek Spy

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld

题目描述

In order to celebrate the admission of new members, Coach Fang resolves to hold a programme named Who is the spy. Participants include Coach Fang, Boss Niu, God Chai, Brother Wang, Teacher Gao and Senior Wang, six persons in total. Initially all of them will be distributed one card which contains a number. It is known that five of the numbers on their cards are identical, and the rest one is different.
Now give you six numbers on the cards, please print the different one.

输入描述:

The first line contains an integer number T, the number of test cases.
ith of each next T lines contains six integers a, b, c, d, e, f(1≤a,b,c,d,e,f≤100).

输出描述:

For each test case print a number, the number which differs from others.

示例1
输入

2
3 4 3 3 3 3
6 6 6 5 6 6

输出

4
5

大声BB

题意很简单就是找一下6个数里面那个数不一样,输出就行了

#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctype.h>
#include<vector>
#include<map>
#include<set>
#include<queue> 
#include<iomanip>
#include<list>
#include<fstream>
using namespace std;
typedef long long ll;
int n[10]={0};
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		for(int i = 0 ;i < 6; i++){
			scanf("%d",&n[i]);
		}
		sort(n,n+6);
		int d ;
		if(n[0]!=n[1]){
			printf("%d\n",n[0]);
			continue;
		}
		if(n[4]!=n[5]){
			printf("%d\n",n[5]);
		}
	} 
	return 0;
}

B- Trial of Devil

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld

题目描述 :

As an acmer, Devil Aguin particularly loves numbers. This time, with a sequence consisting of n elements 1∼n initially, Devil Aguin asks you to process the sequence until all the elements in it turn to zero. What you can do in one operation are as following :
1. Select some elements from the sequence arbitrarily.
2. Select a positive integer x arbitrarily.
3. Subtract x from the elements you select.
It is obvious that there are various methods to make elements of the sequence turn to zero. But Devil Aguin demands of you to use the minimum operations. Please tell him how many operations you will use.

输入描述:

The first line contains an integer number T, the number of test cases.
ith of each next T lines contains one integer n(1≤n≤100), the number of sequence.

输出描述:

For each test case print a number, the minimum number of operations required.

示例1
输入

2
1
2

输出

1
2

大声BB

题意就是给你一个n,(表示1-n的集合)然后让你选择其中的若干个同时减去任意一个数(x),求的是1-n这个集合全部变成0的最小操作步数

刚开始看着题觉得真简单啊,直接输出不就完事了?WA
接下来看着题,严肃,思考,哦原来是可以选择很多个数字的,是可以一起处理的,然后抓了抓脑子,n/2+1,WA
然后,居然又wa了,不会啊,然后自己找例子,到底哪不对,拿13来说
1 2 3 4 5 6 7 8 9 10 11 12 13
先对半开
1 2 3 4 5 6 7 0 1 2 3 4 5 6 7(第一次处理)
欸!不对,两边都是一到七,那后面处理的次数不久和n=7一样了吗
改改,A了

#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctype.h>
#include<vector>
#include<map>
#include<set>
#include<queue> 
#include<iomanip>
#include<list>
#include<fstream>
using namespace std;
typedef long long ll;
int a[105]={0};
void f(){
	a[1]=1;
	a[2]=2;
	for(int i = 3 ; i <= 100 ;i++){
		a[i] = a[i/2] + 1;
	}
}
int main(){
	int t;
	memset(a,0,sizeof(a));
	f();
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		printf("%d\n",a[n]);
	} 
	return 0;
}

M- LCM

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld

题目描述

Silly Slp knows nothing about number theory. One day he feels puzzled with the following problem.
Give two positive integers n and c. Find a pair of positive integer (a, b), which satisfies both of a and b are no more than n and the lowest common multiple of them is c. Moreover, maximize a×b, the product of a and b.
Please tell Silly Slp the maximize value of
a×b. If a and b don’t exist, print “-1”(without quotes).

输入描述:

The first line contains an integer number T, the number of test cases.
ith of each next T lines contains two numbers n and c(1≤n,c≤106).

输出描述:

For each test case print a number, the maximize value.

示例1
输入

2
10 12
5 36

输出

24
-1

大声BB

题意就是说给你两个数,n和c,让你从1-n里选出两个数a,b,要求a,b的最小公倍数是c,输出a,b,a x b的最大值
没找到a,b就输出-1

#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
long long a[100000], t = 0;
long long ans = 0;
int n, m;
int judge2(int a, int b)
{
    if (b == 0) return a;
    else return judge2(b, a % b);
}
 
void judge()
{
    for (int i=0; i<t; i++)
    {
        for (int j=0; j<t; j++)
        {
            if (a[i] * a[j] / judge2(a[i], a[j]) == m)
            {
                ans = max(a[i]*a[j], ans);
            }
        }
    }
}
int main()
{
    int q;
    cin >> q;
    while (q--)
    {  
        t = 0;
        ans = 0;
        memset(a, 0, sizeof(a));
        cin >> n >> m;
        for (int i=1; i<=sqrt(m)+1 && i<=n; i++)
        {
            if (m%i == 0 && m/i<=n)
            {
                a[t++] = i;
                a[t++] = m/i;
            }
        }
        judge();
        if (ans == 0)
            cout << "-1" << endl;
        else
            cout << ans << endl;
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值