結果

問題 No.443 GCD of Permutation
ユーザー olpheolphe
提出日時 2016-11-11 23:16:46
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 854 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 54,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-04 03:07:26
合計ジャッジ時間 2,661 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 RE -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 RE -
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 RE -
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 RE -
testcase_16 AC 2 ms
5,376 KB
testcase_17 RE -
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 2 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
5,376 KB
testcase_29 WA -
testcase_30 RE -
testcase_31 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:31: warning: NULL used in arithmetic [-Wpointer-arith]
   12 |                 if (num[i] == NULL) {
      |                               ^~~~
main.cpp:19:31: warning: NULL used in arithmetic [-Wpointer-arith]
   19 |                 if (num[i] == NULL) {
      |                               ^~~~
main.cpp:27:39: warning: NULL used in arithmetic [-Wpointer-arith]
   27 |                         if (num[i] == NULL) {
      |                                       ^~~~
main.cpp:36:39: warning: NULL used in arithmetic [-Wpointer-arith]
   36 |                         if (num[i] == NULL) {
      |                                       ^~~~
main.cpp:44:31: warning: NULL used in arithmetic [-Wpointer-arith]
   44 |                 if (num[i] == NULL)break;
      |                               ^~~~

ソースコード

diff #

#include "iostream"
using namespace std;

char num[100003];
int sum=0;
unsigned long long int ans=1;
bool flag=true;

int main() {
	cin >> num;
	for (int i = 0;; i++) {
		if (num[i] == NULL) {
			cout << num<<"\n";
			return 0;
		}
		if (num[i] != num[0])break;
	}
	for (int i = 0;; i++) {
		if (num[i] == NULL) {
			ans = 8;
			flag = false;
		}
		if ((int)(num[i] - '0') % 8 != 0)break;
	}
	if (flag) {
		for (int i = 0;; i++) {
			if (num[i] == NULL) {
				ans = 4;
				flag = false;
			}
			if ((int)(num[i] - '0') % 4 != 0)break;
		}
	}
	if (flag) {
		for (int i = 0;; i++) {
			if (num[i] == NULL) {
				ans = 2;
				flag = false;
			}
			if ((int)(num[i] - '0') % 2 != 0)break;
		}
	}
	for (int i = 0;; i++) {
		if (num[i] == NULL)break;
		sum += num[i] - '0';
	}
	while (sum % 3 == 0) {
		sum /= 3;
		ans *= 3;
	}
	cout << ans<<"\n";
	return 0;
}
0