首页 > 其他分享 >SMU Winter 2023 Round #9 (Div.2)

SMU Winter 2023 Round #9 (Div.2)

时间:2023-02-16 22:44:14浏览次数:28  
标签:scanner Winter int max SMU damage nextInt Div.2 Scanner

A.Who is The 19th ZUCCPC Champion

签到题,输出即可。

B.Jiubei and Overwatch

题目:

Jiubei loves playing Overwatch even if it is a long time since the last update. Now he is using a damage skill to kill enemies.

The skill will damage all enemies simultaneously and the damage is determined by the time Jiubei charges this skill. The skill has a charging period division number kk, and two damage increase numbers x,yx,y. If he charged for tt seconds, the damage is calculated as follows:

If t≤k, the damage is t×x.
Otherwise, the damage is k×x+(t−k)×y.
Jiubei has nn enemies, and the ii-th enemy's health is aiai.

Please tell Jiubei how long it takes to charge his skill to kill all of his enemies. Note that the skill can only be used once.

Additionally, an enemy is killed if and only if his health is not greater than the damage he/she take.

思路:

首先找到能够承受伤害最大的敌人,然后再分两种情况求解t。如果前面伤害高的时候就能够击败,就直接用前面的公式计算就可以了。

代码:

点击查看代码
import java.util.Scanner;
public class MainB {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int T = scanner.nextInt();
		while(T-->0) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();
			int x = scanner.nextInt();
			int y = scanner.nextInt();
			int max = 0;
			int now = 0;
			for(int i = 0;i < n;i++) {
				now = scanner.nextInt();
				if(now>max) {
					max = now;
				}
			}
			int t=0;
			if(x*k>max) {
				t = max/x;
				if(max%x!=0) {
					t++;
				}
			}else {
				max = max -k*x;
				t = k+max/y;
				if(max%y!=0) {
					t++;
				}
			}
			System.out.println(t);
		}
	}
}

C.Ah, It's Yesterday Once More

题目:

Boboge remembers The 2021 ICPC Asia Nanjing Regional Contest, Problem D. The problem gives you an array a and asks you how many times the expression "Swap ai and aj" has been executed if you call Sort(a) which is implemented by the following Algorithm 1.

As the algorithm looks quite like the normal bubble sort, Boboge wants you to construct a permutation of length n as the array a, so that the number of times the expression "Swap ai and aj" has been executed equals to the number of times the expression "Swap aj and aj+1" has been executed when we call Sort(a) and BubbleSort(a) respectively.

A permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array), and [1,3,4,5] is also not a permutation (n=4 but there is 5 in the array).

思路:

这道题逆序输出即可。

代码:

点击查看代码
import java.util.Scanner;
public class MainC {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int T = scanner.nextInt();
		while(T-->0) {
			int n = scanner.nextInt();
			for(int i = n;i>0;i--) {
				System.out.print(i+" ");
			}
			System.out.println();
		}
	}
}

F.Sum of Numerators

题目:

给出两个数k和n,给一个序列,分子是1到n,分母是2的k次方,求约分后所有分子的和。

例如:

思路:

首先把没有约分的全部加起来,然后减去一些约分过后的就能得到结果。这种方式用java写会超时,用C++写不会。

代码:

点击查看代码
import java.util.Scanner;
public class MainF {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int T = scanner.nextInt();
		while(T-->0) {
			long n = scanner.nextLong();
			long k = scanner.nextLong();
			long sum = n*(n+1)/2;
	        while(n>0 && k>0){
	        	n >>= 1;
	        	sum -= n*(n+1)/2;
	            k--;
	        }
//	        long m = n;
//	        sum += m*(m+1)/2;	        	
	        System.out.println(sum);
		}
	}
}


标签:scanner,Winter,int,max,SMU,damage,nextInt,Div.2,Scanner
From: https://www.cnblogs.com/Tcoo/p/17093605.html

相关文章

  • SMU 冬令营第五周蓝桥杯模拟赛
    A.[蓝桥杯2021省B2]特殊年份题目:今年是2021年,2021这个数字非常特殊,它的千位和十位相等,个位比百位大1,我们称满足这样条件的年份为特殊年份。输入5个年份,请......
  • ptz2023题解/训练记录 #1 Petrozavodsk Winter Camp 2023 day1 JAGain in Petrozavods
    ProblemA.Agriculture签到题,没看,被队友切了ProblemB.BlocksandExpressions签到题,没看,被队友切了ProblemC.ChangingtheSequences首先,建图吧。然后,二分图最......
  • 1583_AURIX_TC275_SMU的控制以及FSP
    全部学习汇总:​​GreyZhang/g_TC275:happyhackingforTC275!(github.com)​​SMU的软件控制接口主要是实现了一些控制命令,用于控制SMU的状态机以及FSP。具体的内容在上......
  • 1584_AURIX_TC275_SMU的调试以及部分寄存器
    全部学习汇总:​​GreyZhang/g_TC275:happyhackingforTC275!(github.com)​​前面学习的过程中,突然间减速了不少。但是为了保证学习的推进,还是得有每天的稳定输出。我......
  • 1580_AURIX_TC275_SMU模块初步
    全部学习汇总:​​GreyZhang/g_TC275:happyhackingforTC275!(github.com)​​SMU集中了所有软硬件的Alarm信息,这个在之前的很多模块的描述中看得出来的。默认情况下,其......
  • SMU Winter 2023 Round #6 (Div.2)
    A.OP题目:现在请你喊出某次神秘活动中的口号"fengqibisheng,yingyueerlai!"(不包含引号)。思路:这道题输出这句话就行B.Add9Zeros题目:题意就是将数组A中的数加9后拿......
  • SMU Winter 2023 Round #7 (Div.2)
    A.解开束缚缠丝II题意:在一堆字符里面找出最长的回文串,并把它的长度输出出来。思路:这道题,一开始想的是把所有情况都列举出来,然后一一判断是不是回文串。后面根据第二个......
  • SMU冬训营第三周周一
    A.Lucky?题意:给出一个六位数,如果它的前三位之和等于它的后三位之和,就输出"YES",否则输出"NO"。思路:测试样例里面有的六位数不是真正的六位数,有的是‘0’开头的,所以选择......
  • 2023WinterHoliday刷题总结第一弹
    \(2023WinterHoliday\)刷题总结第一弹\(CTF\)\(Web\)1.\(json格式:\)$json['x']=="wllm"\(JSON\)(JavaScriptObjectNotation,JS对象简谱)是一种轻量级的数据交换格式,采......
  • Codeforces Round #844 (Div.1 + Div.2) CF 1782 A~F 题解
    点我看题A.ParallelProjection我们其实是要在这个矩形的边界上找一个点(x,y),使得(a,b)到(x,y)的曼哈顿距离和(f,g)到(x,y)的曼哈顿距离之和最小,求出最小值之后加h就是......