- 2022tysc1451 的博客
【Scanf】【优化】快速读入
- 2025-3-26 18:31:17 @
模板
#define int long long
template<typename type>inline void fin(string intype,type &x){intype=((intype=="%d")?"%lld":intype);scanf(intype.c_str(),&x);}
template<typename type,typename... Args>inline void fin(string intype,type &x,Args&... args){intype=((intype=="%d")?"%lld":intype);scanf(intype.c_str(),&x);fin(intype,args...);}
使用事例
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<typename type>inline void fin(string intype,type &x){intype=((intype=="%d")?"%lld":intype);scanf(intype.c_str(),&x);}
template<typename type,typename... Args>inline void fin(string intype,type &x,Args&... args){intype=((intype=="%d")?"%lld":intype);scanf(intype.c_str(),&x);fin(intype,args...);}
signed main()
{
int a,b;
fin("%d",a,b);
printf("%lld",a+b);
return 0;
}