結果

問題 No.747 循環小数N桁目 Hard
ユーザー math957963
提出日時 2018-10-19 21:42:54
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 995 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 58,976 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-18 20:18:46
合計ジャッジ時間 3,115 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 120
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |         scanf("%s", a);
      |         ~~~~~^~~~~~~~~
main.cpp:65:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   65 |         scanf("%s", a);
      |         ~~~~~^~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	char a[N + 1];
	int b[6];
	b[0] = 4;
	b[1] = 2;
	b[2] = 8;
	b[3] = 5;
	b[4] = 7;
	b[5] = 1;
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	f(i, N + 1)a[i] = 0;
	scanf("%s", a);
	n = strlen(a);
	s = 0;
	f(i, n){
		s += (a[i] - 48);
		s = s % 3;
	}
	if (s == 0){
		if ((a[n - 1] - 48)%2 == 0){
			x = 0;
		}
		else{
			x = 3;
		}
	}
	else if (s == 1){
		if ((a[n - 1] - 48) % 2 == 0){
			x = 4;
		}
		else{
			x = 1;
		}
	}
	else{
		if ((a[n - 1] - 48) % 2 == 0){
			x = 2;
		}
		else{
			x = 5;
		}
	}
	f(i, N + 1)a[i] = 0;
	scanf("%s", a);
	n = strlen(a);
	if (a[n - 1] % 2 == 0){
		if (x == 2)x = 4;
		else if (x == 5)x = 1;
	}

	printf("%d\n", b[x]);


	return 0;
}
0