結果
問題 | No.637 X: Yet Another FizzBuzz Problem |
ユーザー |
![]() |
提出日時 | 2024-05-14 21:44:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,333 bytes |
コンパイル時間 | 385 ms |
コンパイル使用メモリ | 31,232 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-20 10:06:06 |
合計ジャッジ時間 | 1,627 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#include <stdio.h>#include <string.h>// 関数宣言int fizzbuzz_response_length(int n);int main() {int n1,n2,n3,n4,n5;// Dengklek が言った整数を入力scanf("%d %d %d %d %d", &n1,&n2,&n3,&n4,&n5);// fizzbuzz_response_length関数を呼び出して、応答の文字数を取得int response_length = 0;response_length = response_length + fizzbuzz_response_length(n1);response_length = response_length + fizzbuzz_response_length(n2);response_length = response_length + fizzbuzz_response_length(n3);response_length = response_length + fizzbuzz_response_length(n4);response_length = response_length + fizzbuzz_response_length(n5);// 結果を表示printf("%d\n", response_length);return 0;}// fizzbuzz_response_length 関数int fizzbuzz_response_length(int n) {int i=5;int ret=0;if ( n % 3 == 0 && n % 5 == 0) {// "FizzBuzz" の文字数は 8ret=8;} else if (n % 3 == 0) {// "Fizz" の文字数は 4ret=4;} else if (n % 5 == 0) {// "Buzz" の文字数は 4ret=4;} else {// 整数をそのまま返す場合、その整数の文字数を計算char buffer[20]; // 十分に大きなバッファを用意sprintf(buffer, "%d", n);ret=strlen(buffer);}return ret;}