結果
問題 | No.2426 Select Plus or Minus |
ユーザー |
![]() |
提出日時 | 2023-08-18 21:30:00 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 360 bytes |
コンパイル時間 | 1,116 ms |
コンパイル使用メモリ | 28,544 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-28 05:45:07 |
合計ジャッジ時間 | 2,548 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include<stdio.h>char s[100005];int main(){long long int n;scanf("%lld", &n);int k = 0;while (n > 1){if (n % 2 > 0){if (n % 4 < 2){s[k] = '+';n = 3 * n + 1;}else{s[k] = '-';n = 3 * n - 1;}}else{s[k] = '/';n /= 2;}k++;}s[k] = '\0';printf("%d\n%s\n", k, s);return 0;}