Codeforces Round #275 (Div. 2)A,B,C

改进YOLOv9的CT图像肺结节检测与分类算法:从原理到实战 本文将详细介绍如何改进YOLOv9算法,使其更好地适应CT图像肺结节检测与分类任务。我们将从数据集准备、模型改进、训练优化到最终部署,完整呈现一个端到端的深度学习项目,并提供完整的代码实现。 阅读详情
A. Counterexample
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Your friend has recently learned about coprime numbers. A pair of numbers {a, b} is called coprime if the maximum number that divides both a and b is equal to one.

Your friend often comes up with different statements. He has recently supposed that if the pair (a, b) is coprime and the pair (b, c) is coprime, then the pair (a, c) is coprime.

You want to find a counterexample for your friend's statement. Therefore, your task is to find three distinct numbers (a, b, c), for which the statement is false, and the numbers meet the condition l ≤ a < b < c ≤ r.

More specifically, you need to find three numbers (a, b, c), such that l ≤ a < b < c ≤ r, pairs (a, b) and (b, c) are coprime, and pair (a, c) is not coprime.

Input

The single line contains two positive space-separated integers l, r (1 ≤ l ≤ r ≤ 1018; r - l ≤ 50).

Output

Print three positive space-separated integers a, b, c — three distinct numbers (a, b, c) that form the counterexample. If there are several solutions, you are allowed to print any of them. The numbers must be printed in ascending order.

If the counterexample does not exist, print the single number -1.

Sample test(s)
Input
2 4
Output
2 3 4
Input
10 11
Output
-1
Input
900000000000000009 900000000000000029
Output
900000000000000009 900000000000000010 900000000000000021
Note

In the first sample pair (2, 4) is not coprime and pairs (2, 3) and (3, 4) are.

In the second sample you cannot form a group of three distinct integers, so the answer is -1.

In the third sample it is easy to see that numbers 900000000000000009 and 900000000000000021 are divisible by three.



注意到r - l <= 50,所以直接暴力


#include <cmath>  
#include <cstdio>  
#include <cstring>  
#include <iostream>  
#include <algorithm>  

using namespace std;

__int64 gcd(__int64 a, __int64 b)
{
	if (b == 0)
	{
		return a;
	}
	return gcd(b, a % b);
}

int main()
{
	__int64 l, r;
	while (~scanf("%I64d%I64d", &l, &r))
	{
		int a, b, c;
		bool flag = false;
		for (__int64 i = l; i <= r; i++)
		{
			for (__int64 j = i + 1; j <=r ;j ++)
			{
				for (__int64 k = j + 1; k <= r; k++)
				{
					if(gcd(i,j ) == 1 && gcd(j, k) == 1 && gcd(i, k)!= 1)
					{
						printf("%I64d %I64d %I64d\n", i, j, k);
						flag = true;
						break;
					}
				}
				if(flag)
				{
					break;
				}
			}
			if (flag)
			{
				break;
			}
		}
		if(!flag)
		{
			printf("-1\n");
		}
	}
	return 0;
} 

B. Friends and Presents
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to the first friend and cnt2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.

In addition, the first friend does not like the numbers that are divisible without remainder by prime number x. The second one does not like the numbers that are divisible without remainder by prime number y. Of course, you're not going to present your friends numbers they don't like.

Your task is to find such minimum number v, that you can form presents using numbers from a set 1, 2, ..., v. Of course you may choose not to present some numbers at all.

A positive integer number greater than 1 is called prime if it has no positive divisors other than 1 and itself.

Input

The only line contains four positive integers cnt1, cnt2, x, y (1 ≤ cnt1, cnt2 < 109; cnt1 + cnt2 ≤ 109; 2 ≤ x < y ≤ 3·104) — the numbers that are described in the statement. It is guaranteed that numbers x, y are prime.

Output

Print a single integer — the answer to the problem.

Sample test(s)
Input
3 1 2 3
Output
5
Input
1 3 2 3
Output
4
Note

In the first sample you give the set of numbers {1, 3, 5} to the first friend and the set of numbers {2} to the second friend. Note that if you give set {1, 3, 5} to the first friend, then we cannot give any of the numbers 1, 3, 5 to the second friend.

In the second sample you give the set of numbers {3} to the first friend, and the set of numbers {1, 2, 4} to the second friend. Thus, the answer to the problem is 4.

B题比C题难,先搞了这题,比赛中过了但是二测FST了

贴一下我的错误代码,请指教


#include <cmath>  
#include <cstdio>  
#include <cstring>  
#include <iostream>  
#include <algorithm>  

using namespace std;

int main()
{
	int cnt1, cnt2, x, y;
	while (~scanf("%d%d%d%d", &cnt1, &cnt2, &x, &y))
	{
		int l = 1;
		int r = 1000000000;
		int mid;
		int s1, s2, s3;
		int ans;
		int z = x * y;
		while (l <= r)
		{
			mid = (l + r) >> 1;
			s1 = mid / x;
			s2 = mid / y;
			s3 = mid / z;
			s1 -= s3;
			s2 -= s3;
			int t1 = cnt1;
			int t2 = cnt2;
			int t = mid;
			mid -= s3;
			if (t1 > s2)
			{
				t1 -= s2;
				mid -= s2;
			}
			else
			{
				mid -= s2;
				t1 = 0;
			}
			if (t2 > s1)
			{
				t2 -= s1;
				mid -= s1;
			}
			else
			{
				mid -= s1;
				t2 = 0;
			}
			if(mid >= t1 + t2)
			{
				r = t - 1;
				ans = t;
			}
			else
			{
				l = t + 1;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
} 

C. Diverse Permutation
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Permutation p is an ordered set of integers p1,   p2,   ...,   pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,   p2,   ...,   pn.

Your task is to find such permutation p of length n, that the group of numbers |p1 - p2|, |p2 - p3|, ..., |pn - 1 - pn| has exactly k distinct elements.

Input

The single line of the input contains two space-separated positive integers n, k (1 ≤ k < n ≤ 105).

Output

Print n integers forming the permutation. If there are multiple answers, print any of them.

Sample test(s)
Input
3 2
Output
1 3 2
Input
3 1
Output
1 2 3
Input
5 2
Output
1 3 2 4 5
Note

By |x| we denote the absolute value of number x.


大水题,要有k个不同的绝对值之差,就要至少k+1个数,所以我们值动用后面的k+1个数,前面的照样输出,然后只要极端配对就行  比如 23456,配成 26354


#include <cmath>  
#include <cstdio>  
#include <cstring>  
#include <iostream>  
#include <algorithm>  

using namespace std;

int a[100010];

int main()
{
	int n, k;
	while (~scanf("%d%d", &n, &k))
	{
		int i, j;
		for (i = 1; i <= n - k - 1; i++)
		{
			if(i > 1)
				printf(" %d", i);
			else
			{
				printf("%d", i);
			}
		}
		
		if(n - k <= 0)
		{
			printf("\n");
			continue;
		}
		for (i = n - k, j = n; i < j; i++, j--)
		{
			if(i == 1)
				printf("%d %d", i, j);
			else
			{
				printf(" %d %d", i, j);
			}
		}
		if(( k + 1 ) % 2)
		{
			printf(" %d", i);
		}
		printf("\n");
	}
	return 0;
}


数学建模学习(5):最全概率分析之图表绘制详解,内容比较多,建议收藏 (1) 绘制正整数频率使用 tabulate(X)2 阅读详情

相关推荐

SAP MM ME21N保存前检查增强

想在ME21N保存前做一些数据检查, 可以做一个增强功能,  运行 CMOD 新增,   增强接口 输入 MM06E005  (  EXIT_SAPMM06E_012 ) ,在 NCLUDE ZXM06U43 .  里写代码功能。  例子如下: *&---------------------------------------------------------------------*

heng0757的专栏 1万+

筛选法(质数)

Vasya and Petya’s Game Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number. Petya can ask questions like: “Is the unknown number

zhuibushixi的博客 504

Android 中 app freezer 原理详解():S 版本

在之前的两篇博文《Android 中app内存回收优化()》和《Android 中app内存回收优化()》中详细剖析了 Android 中 app 内存优化的流程。这个机制的管理通过 CachedAppOptimizer 类管理,为什么叫这个名字,而不叫 AppCompact 等?freezer,一个针对应用进程长期处于 Cached 状态的优化。在之前博文《app freezer 原理 R 版本》

私房菜 3575

A. Counterexample (Codeforces Round #275(div2)

A. Counterexample time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Your friend has recently learned about cop

ACway的专栏 1322

Codeforces Round #275 (Div. 2)

A. Counterexample time limit per test  1 second memory limit per test  256 megabytes Your friend has recently learned about coprime numbers. A pair of numbers {a, b} is calle

xdlove 1467

Codeforces Round #275 (Div. 2) A,B,C

A 水题了

乐观之奋斗者 576

Codeforces Round #275 (Div. 2) A,B,C,D

A. Counterexample time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Your friend has recently learned about coprime num...

weixin_30458043的博客 120

Codeforces Round #275 (Div. 2) C - Diverse Permutation (构造)

题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n。求一个序列其中相邻两项差的绝对值的个数(指绝对值不同的个数)为k个。求序列、 思路:1~k+1。构造序列前段,之后直接输出剩下的数。前面的构造可以根据,两项差的绝对值为1~k构造。 AC代码: #include #include

n-1 1374

构造 Codeforces Round #275 (Div. 2) C. Diverse Permutation

题目传送门 1 /* 2 构造:首先先选好k个不同的值,从1到k,按要求把数字放好,其余的随便放。因为是绝对差值,从n开始一下一上, 3 这样保证不会超出边界并且以防其余的数相邻绝对值差>k 4 */ 5 /************************************************ 6 Author ...

weixin_30894583的博客 76

codeforces Round #275(div2) D解题报告

题目大意: 假设有n个非负数,现在有m个限制,a[l] & a[l+1] & a[l+2] ... & a[r] = q。要求根据上述的限制,输出符合要求的1~n个数,如若不能则输出“NO”。 解法: 我们先挖掘题意,弄清楚题目给的已知条件和要我们输出什么。 a[l] & a[l+1] & a[l+2] ... & a[r] = q,这是每个限制的基本形式,由“&”我们可以得知,如若q中的某一个bit是1的话,则要求a[l]~a[r]中的那个bit位都为1。这个条件看似是限制

旅行者西瓜 1303

Codeforces Round #275 (Div. 2) c

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33919941的博客 91

Codeforces Round #275 (Div. 2) A

Codeforces Round #275 (Div. 2) A

Notdeep__acm的专栏 988

Codeforces Round #275 (Div. 2) C

Codeforces Round #275 (Div. 2) C

Notdeep__acm的专栏 1369

Codeforces Round #275 (Div. 2) A Counterexample

A Counterexample

gwq5210的专栏 850

Codeforces Round #275 (Div. 2) --A Countexample

题目链接:Counterexample Counterexample time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Your friend

sxk 1153

codeforces Round #275(div2) C解题报告

C. Diverse Permutation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Permutation p is an ordered set of in

旅行者西瓜 938
上一篇: POJ2411——Mondriaan's Dream
下一篇: hdu5083——Instruction
tokers
博客等级 码龄12年 71粉丝 700原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值