結果

問題 No.1235 ζ関数
ユーザー karinohitokarinohito
提出日時 2020-09-26 14:20:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,941 bytes
コンパイル時間 1,005 ms
コンパイル使用メモリ 101,808 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 11:06:26
合計ジャッジ時間 2,306 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,376 KB
testcase_01 AC 16 ms
4,380 KB
testcase_02 AC 16 ms
4,384 KB
testcase_03 AC 17 ms
4,380 KB
testcase_04 AC 7 ms
4,376 KB
testcase_05 AC 17 ms
4,380 KB
testcase_06 AC 16 ms
4,384 KB
testcase_07 AC 17 ms
4,380 KB
testcase_08 AC 17 ms
4,380 KB
testcase_09 AC 17 ms
4,376 KB
testcase_10 AC 17 ms
4,376 KB
testcase_11 AC 17 ms
4,380 KB
testcase_12 AC 17 ms
4,380 KB
testcase_13 AC 17 ms
4,380 KB
testcase_14 AC 17 ms
4,376 KB
testcase_15 AC 17 ms
4,380 KB
testcase_16 AC 6 ms
4,384 KB
testcase_17 AC 16 ms
4,380 KB
testcase_18 AC 16 ms
4,376 KB
testcase_19 AC 16 ms
4,380 KB
testcase_20 AC 16 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘ll binary_search(ll, ll, ll, std::vector<long long int>)’ 内:
main.cpp:50:21: 警告: overflow in conversion from ‘double’ to ‘int’ changes value from ‘1.0e+13’ to ‘2147483647’ [-Woverflow]
   50 |         int right = 1e13;
      |                     ^~~~

ソースコード

diff #

#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}


bool kai(ll A, ll B, ll T,ll N,vector<ll> H) {
	ll an = 0;
	rep(i, N) {
		if (H[i] > B * T) {
			an += max(((H[i] - B * T - 1) / (A - B)) + 1, ll(0));
		}
	}
	if (an <= T) return true;
	else return false;
}
bool isOK(ll A, ll B, ll T, ll N, vector<ll> H) {
	if (kai(A,B,T,N,H)) return true;
	else return false;
}
ll binary_search(ll A,ll B,ll N, vector<ll> H) {
	int left = 0; 
	int right = 1e13; 
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(A,B,mid,N, H)) right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
ll ketawa(ll N) {
	ll ans = 0;
	while (N > 0) {
		ans += N % 10;
		N /= 10;
		
	}
	return ans;
}
int main() {
	cout << fixed << setprecision(20);
	double N;
	cin >> N;
	double an = 0;
	for (double i = 1; i < 1e7 / N; i++) {
		double d = i;
		double k = 1;
		rep(j, N) {
			k *= d;
		}
		an += double(1 / k);
	}
	cout << an << endl;
}
0