0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

エイシング プログラミング コンテスト 2020

Posted at

##A - Number of Multiples

Python
import queue
from math import floor
from decimal import Decimal
 
L, R, d = list(map(int, input().split()))
 
c=0
for i in range(L, R+1):
    if i % d == 0:
        c+=1
 
print(c)

##B - An Odd Problem

Python
N = int(input())
A = list(map(int, input().split()))
 
c = 0
for i in range(N):
    if (i + 1) % 2 == 1 and A[i] % 2 == 1:
        c+=1
print(c)

##C - XYZ Triplets

  • 力技の全探索
  • 計算式から各項目、ループの許容値が分かる
C++
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384
 
using namespace std;
using ll =long long;
using P = pair<int,int>;
 
int N;
int N_array[10001];
 
int main(int argc, const char * argv[]) {
    
    
    cin >> N;
    
    for(int x=1; x*x<=N; x++){
        for(int y=1; x*x+y*y+x*y<=N; y++){
            for(int z=1; z<=N; z++){
                ll ans = x*x + y*y + z*z + x*y + y*z + z*x;
                if(ans <= N){
                    N_array[ans]++;
                }
            }
        }
    }
    
    for(int i=1; i<=N; i++){
        cout << N_array[i] << endl;
    }
    
    return 0;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?