結果
| 問題 | No.1006 Share an Integer |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2020-03-07 00:48:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,160 bytes |
| 記録 | |
| コンパイル時間 | 750 ms |
| コンパイル使用メモリ | 93,576 KB |
| 実行使用メモリ | 98,824 KB |
| 最終ジャッジ日時 | 2024-10-14 10:55:45 |
| 合計ジャッジ時間 | 6,944 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 5 WA * 3 TLE * 2 -- * 9 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1006.cc: No.1006 Share an Integer - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_X = 2000000;
/* typedef */
/* global variables */
int as[MAX_X];
/* subroutines */
inline int f(int n) {
int c = 0;
for (int p = 1; p * p <= n; p++)
if (n % p == 0)
c += (p * p < n) ? 2 : 1;
return n - c;
}
/* main */
int main() {
int x;
scanf("%d", &x);
int mind = x, m = 0;
for (int a = 1; a * 2 <= x; a++) {
int b = x - a;
int d = abs(f(b) - f(a));
//printf("a=%d, b=%d -> d=%d\n", a, b, d);
if (mind > d) {
mind = d;
m = 0;
as[m++] = a;
if (b != a) as[m++] = b;
}
else if (mind == d) {
as[m++] = a;
if (b != a) as[m++] = b;
}
}
for (int i = 0; i < m; i++) printf("%d %d\n", as[i], x - as[i]);
return 0;
}
tnakao0123