2 条题解

  • 1
    @ 2023-12-11 18:02:57
    #include <bits/stdc++.h> 
    using namespace std;
    #define ll unsigned long long
    ll num,sum,n;
    int main(){
        cin>>n;
        for(ll i=1;i<=n;i++)
        {
            if(i%2==1||i%3==1||i%5==1)
            {
                num++;
                sum+=i;
            }
        }
        cout<<num<<endl<<sum;
        return 0;
    }
    
    • 1
      @ 2023-2-10 21:18:29
      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int n, a = 0, x = 0;
      	cin >> n;
      	for (int i = 1; i <= n; i++)
          {
      		if (i % 2 == 1 || i % 3 == 1 || i % 5 == 1)
              {
      			a++;
      			x += i;
      		}
      	}
      	cout << a << endl << x;
      	return 0;
      }
      
      • 1

      信息

      ID
      980
      时间
      1000ms
      内存
      64MiB
      难度
      2
      标签
      递交数
      107
      已通过
      64
      上传者