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)
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++
#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;
}