AtCoder Beginner Contest(ABC)の過去問から、その提出コードの解答例です。
AtCoderとは、コンテストを通じて、プログラミングやアルゴリズムを学習するサービスです。
atcoder.jp
プログラミングコンテストとは、「与えられた問題をいかに素早く、正確に」解くことができるかを競うものです。
「競技プログラミング」を略して、「競プロ」などと呼ばれています。
#B - Small and Large Integers
atcoder.jp
僕が作成、提出したコードは、以下のとおりです。
/* AtCoder Problems in C #B - Small and Large Integers https://atcoder.jp/contests/abc093/tasks/abc093_b 提出コードの解答例 https://neguse-atama.hatenablog.com */ #include<stdio.h> int main(void){ int a,b,k; int min,max; scanf("%d %d %d",&a,&b,&k); int num1=a+k-1; int num2=b-k+1; int num3=a+k; if(b>=num1){ min=num1; }else if(b<=num1){ min=b; } if(num2>=num3){ max=num2; }else if(num2<=num3){ max=num3; } for(int loop=a;loop<=min;loop++){ printf("%d\n",loop); } for(int loop=max;loop<=b;loop++){ printf("%d\n",loop); } return 0; }
/* AtCoder Problems in C++ #B - Small and Large Integers https://atcoder.jp/contests/abc093/tasks/abc093_b 提出コードの解答例 https://neguse-atama.hatenablog.com */ #include<stdio.h> int main(void){ int a,b,k; int min,max; scanf("%d %d %d",&a,&b,&k); int num1=a+k-1; int num2=b-k+1; int num3=a+k; if(b>=num1){ min=num1; }else if(b<=num1){ min=b; } if(num2>=num3){ max=num2; }else if(num2<=num3){ max=num3; } for(int loop=a;loop<=min;loop++){ printf("%d\n",loop); } for(int loop=max;loop<=b;loop++){ printf("%d\n",loop); } return 0; }
AtCoder Beginner Contest(ABC)は、オンラインジャッジによるプログラミングコンテストです。
日本語と英語に対応していて、週末ごとに実施されているみたいです。
https://practice.contest.atcoder.jp/tutorial
アカウントを登録すれば、誰でも参加できます。