- 3210-2020-初赛-Java-1-3
import java.util.*;
import java.io.*;
class Main{
static class Reader {
static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer tokenizer = new StringTokenizer("");
static String next() throws IOException {// 读取下一个字符串
while (!tokenizer.hasMoreTokens()) {
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
static int nextInt() throws IOException {// 读取下一个int型数值
return Integer.parseInt(next());
}
}
public static void main(String[] args) throws IOException {
int n = Reader.nextInt();
int a = Reader.nextInt();
int b =a-1;
int count=0;
for(int i=1;i<=n;i++){
if(i%a==b&&i%2==0) count++;
}
System.out.println(count);
}
}
- 3185-2020-Java-国赛-4-3
注意这里res要用long,不然要超
import java.util.*;
import java.io.*;
class Main{
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
// 获取到输入的字符串
String input = tokenizer.nextToken();
int[] prime;
prime = new int[]{2,3,5,7,11,13,17,19,23,29};
// 处理字符串
int length = input.length();
char[] chars=input.toCharArray();
long temp,res=0;
for(int i = length-1;i>=0;i--){
if(chars[i]<='9') temp= chars[i]-=48;
else temp=chars[i]-=87;
for(int j=length-i-1;j>0;j--){
temp*=prime[j-1];
}
res+=temp;
}
System.out.println(res);
}
}
标签:java,tokenizer,备赛计,int,static,StringTokenizer,new
From: https://www.cnblogs.com/yaocy/p/16864592.html