#include <bits/stdc++.h>
using namespace std;
#define pf emplace_front
#define pb emplace_back
#define ep emplace
#define ppb pop_back
#define ppf pop_front
#define gp make_pair
#define gt make_tuple
#define fr first
#define sd second
#define elif else if
#define PCase(i) (io.write("Case #"),wrt(i),io.write(": "),0)
#define sc(x) static_cast<long long>(x)
#define scd(x) static_cast<double>(x)
#define scD(x) static_cast<long double>(x)
#define ALL1(G) G.begin(),G.end()
#define ALL2(G,x) G.begin()+x,G.end()
#define ALL3(G,x,y) G.begin()+x,G.begin()+y
#define SIZ(G) sc(G.size())
#define For1(a) for(register int i=1,i##_r=(a);i<=i##_r;++i)
#define For2(i,a) for(register int i=1,i##_r=(a);i<=i##_r;++i)
#define For3(i,a,b) for(register int i=(a),i##_r=(b);i<=i##_r;++i)
#define For4(i,a,b,c) for(register int i=(a),i##_r=(b);i<=i##_r;i+=(c))
#define For1R(a) for(register int i=(a);i>=1;--i)
#define For2R(i,a) for(register int i=(a);i>=1;--i)
#define For3R(i,a,b) for(register int i=(a),i##_r=(b);i>=i##_r;--i)
#define For4R(i,a,b,c) for(register int i=(a),i##_r=(b);i>=i##_r;i-=(c))
#define For01(a) for(register int i=0,i##_r=(a);i<i##_r;++i)
#define For02(i,a) for(register int i=0,i##_r=(a);i<i##_r;++i)
#define For03(i,a,b) for(register int i=(a),i##_r=(b);i<i##_r;++i)
#define For04(i,a,b,c) for(register int i=(a),i##_r=(b);i<i##_r;i+=(c))
#define OverLoad(a,b,c,d,e,...) e
#define Overload(a,b,c,d,...) d
#define For(...) OverLoad(__VA_ARGS__,For4,For3,For2,For1)(__VA_ARGS__)
#define ForR(...) OverLoad(__VA_ARGS__,For4R,For3R,For2R,For1R)(__VA_ARGS__)
#define For0(...) OverLoad(__VA_ARGS__,For04,For03,For02,For01)(__VA_ARGS__)
#define ALL(...) Overload(__VA_ARGS__,ALL3,ALL2,ALL1)(__VA_ARGS__)
#define Inline __inline__ __attribute__ ((always_inline))
#define Test() \
register int TestCount=MultiCase?read():1; \
for(register int TestCase=1;TestCase<=TestCount;++TestCase)
#ifdef ONLINE_JUDGE
//when on OJ,close the debug version
#undef Debug
#define Debug(...) 42
#else
//open debug version.
#define register
#define cerr cout
#define Debug(...) cerr << "Debug " << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
template<typename A,typename B>string to_string(pair<A,B>p);
template<typename A,typename B,typename C>string to_string(tuple<A,B,C>p);
template<typename A,typename B,typename C,typename D>string to_string(tuple<A,B,C,D>p);
string to_string(const string&s){return'"'+s+'"';}
string to_string(const char*s){return to_string((string)s);}
string to_string(bool b){return(b?"true":"false");}
string to_string(vector<bool>v){bool first=true;string res="{";for(int i=0;i<static_cast<int>(v.size());i++){if(!first){res+=", ";}first=false;res+=to_string(v[i]);}res+="}";return res;}
template<size_t N>string to_string(bitset<N>v){string res="";for(size_t i=0;i<N;i++){res+=static_cast<char>('0'+v[i]);}return res;}
template<typename A>string to_string(A v){bool first=true;string res="{";for(const auto&x:v){if(!first){res+=", ";}first=false;res+=to_string(x);}res+="}";return res;}
template<typename A,typename B>string to_string(pair<A,B>p){return"("+to_string(p.first)+", "+to_string(p.second)+")";}
template<typename A,typename B,typename C>string to_string(tuple<A,B,C>p){return"("+to_string(get<0>(p))+", "+to_string(get<1>(p))+", "+to_string(get<2>(p))+")";}
template<typename A,typename B,typename C,typename D>string to_string(tuple<A,B,C,D>p){return"("+to_string(get<0>(p))+", "+to_string(get<1>(p))+", "+to_string(get<2>(p))+", "+to_string(get<3>(p))+")";}
inline void debug_out(){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(Head H,Tail...T){cerr<<" "<<to_string(H);debug_out(T...);}
#endif
template<class T>Inline T Min(register T a,register T b){return a<b?a:b;}
template<class T>Inline T Max(register T a,register T b){return a>b?a:b;}
template<class T,class Q>Inline bool Cmin(register T&a,register Q b){return a>b?(a=b,true):false;}
template<class T,class Q>Inline bool Cmax(register T&a,register Q b){return a<b?(a=b,true):false;}
#define UseBuffer
struct IO{
#ifdef UseBuffer
//unlockeds somtimes are a little faster than normals
//#define fread fread_unlocked
//#define fwrite fwrite_unlocked
const static int BUFSIZE=1<<20;
char buf[BUFSIZE],obuf[BUFSIZE],*p1,*p2,*pp;
inline char getchar(){return(p1==p2&&(p2=(p1=buf)+fread(buf,1,BUFSIZE,stdin),p1==p2)?EOF:*p1++);}
inline void putchar(char x){((pp-obuf==BUFSIZE&&(fwrite(obuf,1,BUFSIZE,stdout),pp=obuf)),*pp=x,pp++);}
inline IO&flush(){fwrite(obuf,1,pp-obuf,stdout);fflush(stdout);return*this;}
IO(){p1=buf,p2=buf,pp=obuf;}
~IO(){flush();}
#else
//remember to flush in interactive problems
//int(*getchar)()=&::getchar_unlocked;
//int(*putchar)(int)=&::putchar_unlocked;
int(*getchar)()=&::getchar;
int(*putchar)(int)=&::putchar;
inline IO&flush(){fflush(stdout);return*this;};
#endif
int k=2;
string sep=" ";
template<typename Tp,typename enable_if<is_integral<Tp>::value||is_same<Tp,__int128_t>::value>::type* =nullptr>inline int read(Tp&s){int f=1;char ch=getchar();s=0;while(!isdigit(ch)&&ch!=EOF)f=(ch=='-'?-1:1),ch=getchar();while(isdigit(ch))s=s*10+(ch^48),ch=getchar();s*=f;return ch!=EOF;}
template<typename Tp,typename enable_if<is_floating_point<Tp>::value>::type* =nullptr>inline int read(Tp&s){int f=1;char ch=getchar();s=0;while(!isdigit(ch)&&ch!=EOF&&ch!='.')f=(ch=='-'?-1:1),ch=getchar();while(isdigit(ch))s=s*10+(ch^48),ch=getchar();if(ch==EOF)return false;if(ch=='.'){Tp eps=0.1;ch=getchar();while(isdigit(ch))s=s+(ch^48)*eps,ch=getchar(),eps/=10;}s*=f;return ch!=EOF;}
inline int read(char&c){char ch=getchar();c=EOF;while(isspace(ch)&&ch!=EOF)ch=getchar();if(ch!=EOF)c=ch;return c!=EOF;}
inline int read(char*c){char ch=getchar(),*s=c;while(isspace(ch)&&ch!=EOF)ch=getchar();while(!isspace(ch)&&ch!=EOF)*(c++)=ch,ch=getchar();*c='\0';return s!=c;}
inline int read(string&s){s.clear();char ch=getchar();while(isspace(ch)&&ch!=EOF)ch=getchar();while(!isspace(ch)&&ch!=EOF)s+=ch,ch=getchar();return s.size()>0;}
inline int getline(char*c,const char&ed='\n'){char ch=getchar(),*s=c;while(ch!=ed&&ch!=EOF)*(c++)=ch,ch=getchar();*c='\0';return s!=c;}
inline int getline(string&s,const char&ed='\n'){s.clear();char ch=getchar();while(ch!=ed&&ch!=EOF)s+=ch,ch=getchar();return s.size()>0;}
template<typename Tp=int>inline Tp read(){Tp x;read(x);return x;}
template<typename Tp,typename...Ts>int read(Tp&x,Ts&...val){return read(x)&&read(val...);}
template<typename Tp,typename enable_if<is_integral<Tp>::value>::type* =nullptr>IO&write(Tp x){if(x<0)putchar('-'),x=-x;static char sta[114];int top=0;do sta[top++]=x%10+'0',x/=10;while(x);while(top)putchar(sta[--top]);return*this;}
inline IO&write(const string&str){for(char ch:str)putchar(ch);return*this;}
inline IO&write(const char*str){while(*str!='\0')putchar(*(str++));return*this;}
inline IO&write(char*str){return write((const char*)str);}
inline IO&write(const char&ch){return putchar(ch),*this;}
template<typename Tp,typename enable_if<is_floating_point<Tp>::value>::type* =nullptr>inline IO&write(Tp x){if(x>1e18||x<-1e18){write("[Floating point overflow]");throw;}if(x<0)putchar('-'),x=-x;const static long long pow10[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000,100000000000,1000000000000,10000000000000,100000000000000,1000000000000000,10000000000000000,100000000000000000,100000000000000000,100000000000000000};const auto&n=pow10[k];long long whole=(int)x;double tmp=(x-whole)*n;long long frac=tmp;double diff=tmp-frac;if(diff>0.5){++frac;if(frac>=n)frac=0,++whole;}else if(diff==0.5&&((frac==0U)||(frac&1U)))++frac;write(whole);if(k==0U){diff=x-(double)whole;if((!(diff<0.5)||(diff>0.5))&&(whole&1))++whole;}else{putchar('.');static char sta[20];int count=k,top=0;while(frac){sta[top++]=frac%10+'0';frac/=10,count--;}while(count--)putchar('0');while(top)putchar(sta[--top]);}return*this;}
template<typename Tp,typename...Ts>inline IO&write(Tp x,Ts...val){write(x);write(sep);write(val...);return*this;}
template<typename...Ts>inline IO&writeln(Ts...val){write(val...);putchar('\n');return*this;}
inline IO&writeln(void){putchar('\n');return*this;}
template<typename Tp>inline IO&writeWith(Tp x,const string&s=" "){write(x),write(s);return*this;}
inline IO&setsep(const string&s){return sep=s,*this;}
inline IO&setprec(const int&K){return k=K,*this;}
}io;
inline int rd(){return io.read<int>();}
inline long long read(){return io.read<long long>();}
inline unsigned long long Read(){return io.read<unsigned long long>();}
template<class T,size_t x>inline void readsp(array<T,x>&G){For0(x)io.read(G[i]);return void();}
template<class T,class Q>inline void readsp(pair<T,Q>&x){io.read(x.first,x.second);return void();}
template<class T,class...Args>inline void readsp(T&x,Args&...args){readsp(x);readsp(args...);return void();}
template<class T>inline bool wrt(T x){return io.write(x),true;}
template<class T>inline bool Write(T x,string ch="\n"){return io.writeWith(x,ch),true;}
template<class...T>inline bool write(T...x){io.write(x...);io.putchar('\n');return true;}
template<class T,size_t x>inline bool writesp(const array<T,x>&G){For0(x)Write(G[i],i==x-1?"\n":" ");return true;}
template<class T,class Q>inline bool writesp(const pair<T,Q>&x){Write(x.first," ");write(x.second);return true;}
template<class T>inline bool writesp(vector<T>&G){if(G.empty())return false;register int sz=SIZ(G)-1;For(sz){Write(G[i],i==sz?"\n":" ");}return true;}
template<class T,class...Args>inline bool writesp(T x,Args&...args){writesp(x);writesp(args...);return true;}
inline bool WRITE(__int128 x,char ch='\n'){if(x<0)io.putchar('-'),x=-x;static char sta[114];int top=0;do sta[top++]=x%10+'0',x/=10;while(x);while(top)io.putchar(sta[--top]);io.putchar(ch);return true;}
using tp=long long;
using i128=__int128;
using u32=unsigned;
using u64=unsigned long long;
using u128=unsigned __int128;
using d32=double;
using d64=long double;
using d128=__float128;
template<class T,class Q>using pr=pair<T,Q>;
template<class T=tp>using vc=vector<T>;
using pt=pr<tp,tp>;
[[maybe_unused]]constexpr long long N=1000100;bool MultiCase;
inline int SolveMain([[maybe_unused]]long long TC);
inline void InitMain();
#if 1
int main(){
// OF("test");
InitMain();
Test()SolveMain(TestCase);
return 0;
}
#endif
inline void InitMain(){
MultiCase=false;
return void();
}剪贴板
剪贴板 r3uikv9r
剪贴板信息
剪贴板信息
- 收录
- 更新