备赛计挑

  • 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);
}
}

本文作者:YaosGHC

本文链接:https://www.cnblogs.com/yaocy/p/16864592.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   YaosGHC  阅读(24)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起