Official
A - Arithmetic Progression Editorial by en_translator
For beginners
- If you are new to learning programming and do not know where to start, please try Problem A "Welcome to AtCoder" from practice contest. There you can find a sample code for each language.
- Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in "AtCoder Beginners Selection".
- 「C++入門 AtCoder Programming Guide for beginners (APG4b)」 is a C++ tutorial for competitive programmers. Sadly, this is only in Japanese too.
Simply put, the problem asks to print integers starting from \(A\), incrementing by \(D\), up to \(B\). One can implement it by appropriately using a for statement or a while statement.
Sample code (C++)
#include <bits/stdc++.h>
using namespace std;
int main(){
int a, b, d;
cin >> a >> b >> d;
for(int n=a; n<=b; n+=d){
cout << n << (n==b?'\n':' ');
}
}
Sample code (Python)
A,B,D = map(int,input().split())
print(*range(A,B+1,D))
posted:
last update: