2 solutions

  • 0
    @ 2025-11-18 21:38:29

    解题报告

    撰写人: 陈天翊

    题意分析

    这里有 10 10 个苹果,小 A 拿走了 2 2 个,Uim 拿走了 4 4 个,八尾勇拿走剩下的所有的苹果。我们想知道:

    小A 和 Uim 两个人一共拿走多少苹果? 八尾勇能拿走多少苹果? 现在需要编写一个程序,输出两个数字作为答案,中间使用空格分开。

    输入格式 不需要输入。

    输出格式 输出两个数字作为答案,中间使用空格分开。

    难度等级

    ★★★★★

    解题思路

    输出两个数字作为答案,中间使用空格分开。

    解题反思

    :)

    参考程序

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        cout<<6<<" "<<4;
        return 0;
    }
    
    • -1
      @ 2025-11-11 17:30:24

      解题报告

      撰写人: ༺༺劳༒大༻༻

      题意分析

      表示区间[a, b]内质数的个数。

      难度等级

      ★★★☆☆

      解题思路

      用一个自定义函数判断一个数是否为质数,如果是,s加1。

      参考程序

      #include<bits/stdc++.h>
      using namespace std;
      
      int a,b,s;
      bool isPrime(int x){
      	if(x==2) return true;
      	for(int i=2;i<=sqrt(x);++i){
      		if(x%i==0) return false;
      	}
      	return true;
      }
      
      int main(){
      	
      	cin>>a>>b;
      	for(int i=a;i<=b;++i){
              if(isPrime(i)) ++s;
          }
          cout<<s;
      	
      	return 0;
      }
      
      • 1

      Information

      ID
      482
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      5
      Tags
      (None)
      # Submissions
      65
      Accepted
      24
      Uploaded By