
- import java.util.*;
-
- public class Main
- {
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- int n=sc.nextInt();
- String[] name=sc.nextLine().split(" ");
- Set
st=new HashSet<>(); - for(int i=0;i
- int k=sc.nextInt();
- double sum=0;
- Set
res=new TreeSet<>(); - Map
mp=new HashMap<>(); - int temp=k;
- while(k-->0)
- {
- String x=sc.next();
- int t=sc.nextInt();
- mp.put(x,t);
- sum+=t;
- }
- sum/=temp;
- for(Map.Entry
x:mp.entrySet()) - {
- if(!st.contains(x.getKey())&&x.getValue()>sum) res.add(x.getKey());
- }
- if(res.size()==0) System.out.print("Bing Mei You");
- else for(String x:res) System.out.println(x);
- }
- }
2、c++
- #include
- using namespace std;
-
- int main()
- {
- int n;
- cin>>n;
- set
st; - for(int i=0;i
- {
- string s;
- cin>>s;
- st.insert(s);
- }
- int k,temp;
- double sum=0;
- cin>>k;
- temp=k;
- map
int>mp; - while(k--)
- {
- string x;
- int t;
- cin>>x>>t;
- mp[x]=t;
- sum+=t;
- }
- sum/=temp;
- set
res; - for(auto x:mp)
- if(!st.count(x.first)&&x.second>sum) res.insert(x.first);
- if(res.size()==0) cout<<"Bing Mei You";
- else for(auto x:res) cout<
- }
L1-027 出租 - 20
- import java.util.*;
-
- public class Main
- {
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- String s=sc.next();
- TreeSet
st=new TreeSet<>(Comparator.reverseOrder()); - for(int i=0;i
- System.out.print("int[] arr = new int[]{");
- int cnt=0;
- Map
mp=new HashMap<>(); - for(char x:st)
- {
- System.out.print(x);
- mp.put(x,cnt);
- cnt++;
- if(cnt!=st.size()) System.out.print(",");
- }
- System.out.println("};");
- System.out.print("int[] index = new int[]{");
- int res=0;
- for(int i=0;i
- {
- res++;
- System.out.print(mp.get(s.charAt(i)));
- if(res!=s.length()) System.out.print(",");
- }
- System.out.print("};");
- }
- }
L1-025 正整数A+B - 15
要注意 不能用split按空格分割
因为有多个空格存在时 比如123 123 kkk
如果按split分割 则就是123+123=246
但正确答案应该是123+?=?
- import java.util.*;
-
- public class Main
- {
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- String s=sc.nextLine();
- String[] a=new String[2];
- a[0]=s.substring(0,s.indexOf(" "));
- a[1]=s.substring(s.indexOf(" ")+1);
- boolean f1=false,f2=false;
- if(isDigit(a[0])) f1=true;
- if(isDigit(a[1])) f2=true;
- if(f1&&f2)
- {
- Integer s1=Integer.parseInt(a[0]);
- Integer s2=Integer.parseInt(a[1]);
- System.out.print(a[0]+" + "+a[1]+" = "+(s1+s2));
- }
- else if(!f1&&f2) System.out.print("? + "+a[1]+" = ?");
- else if(f1&&!f2) System.out.print(a[0]+" + ? = ?");
- else System.out.print("? + ? = ?");
- }
-
- public static boolean isDigit(String s)
- {
- if(s.charAt(0)=='0'||(s.length()>3&&!"1000".equals(s))) return false;
- for(int i=0;i
- if((s.charAt(i)-'0')<0||(s.charAt(i)-'0')>9)
- return false;
- return true;
- }
- }
L1-028 判断素数 - 10
- import java.util.*;
-
- public class Main
- {
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- int n=sc.nextInt();
- while(n-->0)
- {
- int x=sc.nextInt();
- if(isprime(x)) System.out.println("Yes");
- else System.out.println("No");
- }
- }
-
- public static boolean isprime(int n)
- {
- if(n==0||n==1) return false;
- for(int i=2;i<=n/i;i++) if(n%i==0) return false;
- return true;
- }
- }
-
相关阅读:
电脑版剪映怎么倒放?
Java 8 新特性 Ⅰ
html中登录按钮添加回车键登录
《安富莱嵌入式周报》第283期:全开源逆向“爆破”硬件工具,Linux内核6.1将正式引入RUST语言,I3C培训教程,80款市场成熟的电感式位置传感器设计
NoSQL之Redis配置与优化(一)
PDF图片提取的方法有什么?这个方法1分钟提取完毕
SQL注入漏洞(原理篇)
QCSPCChart for Java R3x0 Crack
Matlab|基础知识总结一
【AI视野·今日Robot 机器人论文速览 第八十四期】Thu, 7 Mar 2024
-
原文地址:https://blog.csdn.net/weixin_61639349/article/details/127887375
-
最新文章
-
沪漂五周年了:我越来越迷茫了
Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
MySQL-Seconds_behind_master的精度误差
[MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
Agent OS :五种驯服不确定性的范式
PortSwigger SQL注入LAB11
数据库即时编译JIT
[Begin]AI Learn Data Day 0
深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU