結果

問題 No.2971 無理積分
ユーザー clever-elsie
提出日時 2025-01-17 00:30:29
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 8,900 bytes
コンパイル時間 6,623 ms
コンパイル使用メモリ 352,908 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-17 00:31:16
合計ジャッジ時間 40,832 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#if __has_include(<atcoder/all>)
#include<atcoder/all>
using namespace atcoder;
using mint=modint998244353;
using mint1=modint1000000007;
#endif
#if __has_include(<ext/pb_ds/assoc_container.hpp>) && __has_include(<ext/pb_ds/tree_policy.hpp>)
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class s,class t>using __gnu_map=tree<s,t,std::less<s>,rb_tree_tag,tree_order_statistics_node_update>;
template<class s,class t>struct gnu_map:public __gnu_map<s,t>{
	using iterator=typename __gnu_map<s,t>::iterator;
	iterator get(int64_t idx){return this->find_by_order(idx<0?this->size()-idx:idx);}
	size_t ord(const s&key){return this->order_of_key(key);}
};
#endif
template<class s>struct gnu_set:public gnu_map<s,null_type>{gnu_map<s,null_type>::iterator operator[](int64_t i){return this->get(i);}};
#include <bits/stdc++.h>
using namespace std;
using std::cin;
using std::cout;
using sstream=stringstream;
#define RET return
#define int long long
#define itn long long
#define fi first
#define se second
#define endl '\n'
#define sn(i,c) " \n"[i==c];
#define rsv(n) reserve(n)
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define ppf() pop_front()
#define ppb() pop_back()
#define pp() pop()
#define ins(a) insert(a)
#define emp(...) emplace(__VA_ARGS__)
#define ers(a) erase(a)
#define cont(a) contains(a)
#define mp(f,s) make_pair(f,s)
#define A(a) begin(a),end(a)
#define I(a,i) begin(a),begin(a)+(i)
#define elif(c) else if(c)
#define _SEL4(_1,_2,_3,_4,name,...) name
#define _SEL3(_1,_2,_3,name,...) name
#define _REP4(i,s,n,st) for(int i=(s);i<(n);i+=(st))
#define _REP3(i,s,n) _REP4(i,s,n,1)
#define _REP2(i,n) _REP3(i,0,n)
#define _REP1(n) _REP2(_,n)
#define _RREP4(i,n,t,s) for(int i=(n);i>=(t);i-=(s))
#define _RREP3(i,n,t) _RREP4(i,n,t,1)
#define _RREP2(i,n) _RREP3(i,n,0)
#define _ITER2(x,a) for(auto&x:a)
#define _ITER3(x,y,a) for(auto&[x,y]:a)
#define _CTER2(x,a) for(const auto&x:a)
#define _CTER3(x,y,a) for(const auto&[x,y]:a)
#define rep(...) _SEL4(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define rrep(...) _SEL4(__VA_ARGS__,_RREP4,_RREP3,_RREP2,_REP1)(__VA_ARGS__)
#define forif(c,...) rep(__VA_ARGS__)if(c)
#define iter(...) _SEL3(__VA_ARGS__,_ITER3,_ITER2)(__VA_ARGS__)
#define cter(...) _SEL3(__VA_ARGS__,_CTER3,_CTER2)(__VA_ARGS__)
#define _LB_BEX(b,e,x) lower_bound(b,e,x)
#define _LB_BEXG(b,e,x,g) lower_bound(b,e,x,g)
#define _UB_BEX(b,e,x) upper_bound(b,e,x)
#define _UB_BEXG(b,e,x,g) upper_bound(b,e,x,g)
#define lb(...) _SEL4(__VA_ARGS__,_LB_BEXG,_LB_BEX)(__VA_ARGS__)
#define ub(...) _SEL4(__VA_ARGS__,_UB_BEXG,_UB_BEX)(__VA_ARGS__)
#define rev(a) reverse(A(a))
#define minel(a) min_element(A(a))
#define maxel(a) max_element(A(a))
#define acm(a) accumulate(A(a),0ll)
#define nxpm(a) next_permutation(A(a))
#define Sort(a) sort(A(a))
#define uni(a) Sort(a);a.erase(unique(A(a)),a.end())
#define swapcase(a) a=(isalpha(a)?a^32:a)
#define NL cout<<'\n'
template<class f>using gr=greater<f>;
template<class f>using vc=vector<f>;
template<class f>using vv=vc<vc<f>>;
template<class f>using v3=vv<vc<f>>;
template<class f>using v4=vv<vv<f>>;
template<class f>using pq=priority_queue<f>;
template<class f>using pqg=priority_queue<f, vc<f>, gr<f>>;
#define uset unordered_set
#define umap unordered_map
using i8=int8_t; using i16=int16_t; using i32=int32_t; using i64=int64_t; using i128=__int128_t;
using u8=uint8_t;using u16=uint16_t;using u32=uint32_t;using u64=uint64_t;using u128=__uint128_t;
using intw=__int128_t;using uintw=__uint128_t;
using f32=float;using f64=double;using f128=long double;
using vi=vc<int>;using vb=vc<bool>;
using pi=pair<int,int>;
using str=string;using vs=vc<str>;
using pqgp=pqg<pi>;
#define double f128
constexpr int inf=1ll<<60,minf=-inf;
constexpr char sep='\n';
constexpr array<pi,8>dc={{{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}}};
template<class T,class U>inline void chmax(T&a,const U&b){if(a<b)a=b;}
template<class T,class U>inline void chmin(T&a,const U&b){if(a>b)a=b;}
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define yn(c) (c)?yes:no
#if __cplusplus <= 202002L
#else
#define C const
namespace vies=std::views;
#define DR(i) views::drop(i)
#define TK(i) views::take(i)
#define RV views::reverse
#define IOTA vies::iota
#define INT(...) int __VA_ARGS__;getv(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;getv(__VA_ARGS__)
#define STR(...) str __VA_ARGS__;getv(__VA_ARGS__)
#define VI(a,n) vi a(n);getv(a)
#define VS(a,n) vs a(n);getv(a)
#define UV(u,v) INT(u,v);u--,v--
#define UVW(u,v,w) INT(u,v,w);u--,v--
template<integral T,integral U>inline auto ceil(C T a,C U b){return(a+b-1)/b;}
template<integral T,integral U>inline auto floor(C T a,C U b){return a/b-(a%b&&(a^b)<0);}
template<class T,class U>concept LUBI= same_as<T,vc<U>>||same_as<T,deque<U>>||is_array_v<T>;
#define TP template<class T,class U,typename cp=less<U>>
#define RL requires LUBI<T,U>
TP u64 lbi(C T&v,C U&x,cp cmp=cp())RL{RET lb(A(v),x,cmp)-begin(v);}
TP u64 ubi(C T&v,C U&x,cp cmp=cp())RL{RET ub(A(v),x,cmp)-begin(v);}
TP u64 lbi(u64 i,C T&v,C U&x,cp cmp=cp())RL{RET lb(i+A(v),x,cmp)-begin(v);}
TP u64 ubi(u64 i,C T&v,C U&x,cp cmp=cp())RL{RET ub(i+A(v),x,cmp)-begin(v);}
TP u64 lbi(C T&v,u64 i,C U&x,cp cmp=cp())RL{RET lb(I(v,i),x,cmp)-begin(v);}
TP u64 ubi(C T&v,u64 i,C U&x,cp cmp=cp())RL{RET ub(I(v,i),x,cmp)-begin(v);}
TP u64 lbi(u64 i,C T&v,u64 e,C U&x,cp cmp=cp())RL{RET lb(i+I(v,e),x,cmp)-begin(v);}
TP u64 ubi(u64 i,C T&v,u64 e,C U&x,cp cmp=cp())RL{RET ub(i+I(v,e),x,cmp)-begin(v);}
#undef TP
#undef RL
#define TP template
TP<class T>concept Lint=is_integral_v<T>&&sizeof(T)>8;
TP<Lint T>ostream&operator<<(ostream&dst,T val){
	ostream::sentry s(dst);
	if(!s)return dst;
	char _O128[64];
	char*d=end(_O128);
	bool vsign=val<0;
	uintw v=val;
	if(vsign&&val!=numeric_limits<T>::min())v=1+~(uintw)val;
	do{
		*(--d)="0123456789"[v%10];
		v/=10;
	}while(v!=0);
	if(vsign)*(--d)='-';
	size_t len=end(_O128)-d;
	if(dst.rdbuf()->sputn(d,len)!=len)dst.setstate(ios_base::badbit);
	return dst;
}
TP<Lint T>istream&operator>>(istream&src,T&val) {
	str s;src>>s;
	bool is_neg=numeric_limits<T>::is_signed&&s.size()>0&&s[0]=='-';
	for(val=0;C auto&x:s|views::drop(is_neg))val=10*val+x-'0';
	if(is_neg)val*=-1;
	return src;
}
#define MUT make_unsigned_t
TP<integral T>i32 pcnt(T p){return popcount(MUT<T>(p));}
TP<integral T>i32 lsb(T p){return countl_zero(MUT<T>(p));}
TP<integral T>i32 msb(T p){return countr_zero(MUT<T>(p));}
TP<class T>concept Itrabl=requires(C T&x){x.begin();x.end();};
TP<class T>concept IItrabl=Itrabl<T>&&Itrabl<typename T::value_type>;
TP<class T>concept ModInt=requires(C T&x){x.val();};
void _getv(str&a){cin>>a;}
TP<class T>void _getv(T&a){cin>>a;}
TP<class T,class U>void _getv(pair<T,U>&a){_getv(a.fi);_getv(a.se);}
TP<Itrabl T>void _getv(T&a){iter(x,a)_getv(x);}
TP<class T>void getv(T&a){_getv(a);}
TP<class T,class... Ts>void getv(T&a,Ts&... b){_getv(a);getv(b...);}
ostream*dos=&cout;
void _putv(C str&a){(*dos)<<a<<sep;}
TP<class T>void _putv(C T&a){(*dos)<<a<<' ';}
TP<class T,class U>void _putv(C pair<T,U>&a){_putv(a.fi);_putv(a.se);}
TP<ModInt T>void _putv(C T&a){_putv(a.val());}
TP<Itrabl T>void _putv(C T&a){cter(x,a)_putv(x);(*dos)<<sep;}
TP<IItrabl T>void _putv(C T&a){cter(y,a)_putv(y);}
TP<IItrabl T>void _putv(C T&a)requires same_as<typename T::value_type,str>{cter(x,a)_putv(x);}
TP<class T>void putv(C T&a){_putv(a);(*dos)<<sep;}
TP<class T,class... Ts>void putv(C T&a,C Ts&... b){_putv(a);putv(b...);}
TP<i32 N,integral T> void putbit(T s,char sep='\n'){
	char buf[N+1]={0};
	for(char*itr=buf+N-1;itr>=buf;itr--,s>>=1)
		*itr='0'+(s&1);
	cout<<buf<<sep;
}
#undef TP
#undef C
#endif
#ifdef LOCAL
#define dput(...) dos=&cerr;putv(__VA_ARGS__);dos=&cout
#else
#define dput(...)
#endif

int n,n3;
f128 a;

f128 sqrtld(f128 n){
	f128 l=0,r=n;
	while(r-l>=1e-12){
		f128 m=(l+r)/2.0;
		if(m*m<=n)l=m;
		else r=m;
	}
	return l;
}

void cpre(f128&pre1,f128&pre0){
	pre1/=3.0;
	pre0/=3.0;
	f128 p1=(1+n)*sqrtld(n+1);
	f128 p0=n*sqrtld(n);
	pre0*=p0;
	pre1*=p1;
}

f128 ct(f128&t){
	f128 sq=t;
	f128 lg=a;
	sq*=sqrtld(fma(t,t,a));
	lg*=log(fabs(t+sqrtld(fma(t,t,a))));
	return sq+lg;
}
void cpost(f128&post1,f128&post0){ // 1/2(x\sqrt{t^2+A} + A log|t+\sqrt{t^2+A}|)
	a=n*n;
	a*=0.75;
	f128 t0=-f128(n)/2.0;
	f128 t1=1+t0;
	f128 p1=ct(t1);
	f128 p0=ct(t0);
	post1*=p1;
	post0*=p0;
}

f128 f(f128 x){
	return sqrt(x*x*x+n3);
}

f128 calc(f128 a,f128 b){
	f128 divide=3e8;
	f128 w=1/divide;
	f128 ans=0;
	for(f128 x=a;x<=b;x+=w)
		ans+=w*f(x);
	return ans;
}

void slv(){
	getv(n);
	n3=n*n*n;
	if(n){
		//f128 pre1=2,pre0=2,post1=0.5,post0=0.5;
		//cpre(pre1,pre0);
		//cpost(post1,post0);
		//putv(pre1*post1+pre0*post0-(pre1*post0+post1*pre0));
		putv(calc(0,1));
	}else{
		putv(0.4);
	}
}

signed main(){
	cin.tie(0)->sync_with_stdio(0);
	cout<<fixed<<setprecision(6);
	slv();
}
0