标签:standard ext find ann htm ret limit nts required
https://beta.atcoder.jp/contests/abc103
A - Task Scheduling Problem
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 100100 points
You have three tasks, all of which need to be completed.
First, you can complete any one task at cost 00.
Then, just after completing the ii-th task, you can complete the jj-th task at cost |Aj−Ai||Aj−Ai|.
Here, |x||x| denotes the absolute value of xx.
Find the minimum total cost required to complete all the task.
Input is given from Standard Input in the following format:
A1A1 A2A2 A3A3
Print the minimum total cost required to complete all the task.
1 6 3
5
When the tasks are completed in the following order, the total cost will be 55, which is the minimum:
11 5 5
6
100 100 100
0
import java.util.Arrays; import java.util.Scanner; import static java.lang.Math.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int [] a = new int[3]; for(int i = 0;i < 3;i ++) { a[i] = in.nextInt(); } Arrays.sort(a); System.out.println(a[2] - a[0]); } }
B - String Rotation
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 200200 points
You are given string SS and TT consisting of lowercase English letters.
Determine if SS equals TT after rotation.
That is, determine if SS equals TT after the following operation is performed some number of times:
Operation: Let S=S1S2...S|S|S=S1S2...S|S|. Change SS to S|S|S1S2...S|S|−1S|S|S1S2...S|S|−1.
Here, |X||X| denotes the length of the string XX.
Input is given from Standard Input in the following format:
SS TT
If SS equals TT after rotation, print Yes
; if it does not, print No
.
kyoto tokyo
Yes
kyoto
becomes okyot
.okyot
becomes tokyo
.abc arc
No
abc
does not equal arc
after any number of operations.
aaaaaaaaaaaaaaab aaaaaaaaaaaaaaab
Yes
import java.util.Arrays; import java.util.Scanner; import static java.lang.Math.*; public class Main { static boolean check(String a,String b) { if(a.length() != b.length())return false; for(int i = 0;i < a.length();i ++) { if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) { return true; } } return false; } public static void main(String[] args) { Scanner in = new Scanner(System.in); String a = in.nextLine(); String b = in.nextLine(); System.out.println(check(a,b) ? "Yes" : "No"); } }
标签:standard ext find ann htm ret limit nts required
原文地址:https://www.cnblogs.com/8023spz/p/9360349.html