SGU 118
来源:互联网 发布:照片在线合成软件 编辑:程序博客网 时间:2024/04/30 10:28
本来想用大数模版暴力搞的。。。汗。。。
#include<iostream>#include<vector>#include<algorithm>#include<cstdio>#include<queue>#include<stack>#include<string>#include<map>#include<set>#include<cmath>#include<cassert>#include<cstring>#include<iomanip>using namespace std;#ifdef _WIN32#define i64 __int64#define out64 "%I64d\n"#define in64 "%I64d"#else#define i64 long long#define out64 "%lld\n"#define in64 "%lld"#endif#define FOR(i,a,b) for( int i = (a) ; i <= (b) ; i ++)#define FF(i,a) for( int i = 0 ; i < (a) ; i ++)#define FFD(i,a) for( int i = (a)-1 ; i >= 0 ; i --)#define S64(a) scanf(in64,&a)#define SS(a) scanf("%d",&a)#define LL(a) ((a)<<1)#define RR(a) (((a)<<1)+1)#define SZ(a) ((int)a.size())#define PP(n,m,a) puts("---");FF(i,n){FF(j,m)cout << a[i][j] << ' ';puts("");}#define pb push_back#define CL(Q) while(!Q.empty())Q.pop()#define MM(name,what) memset(name,what,sizeof(name))#define read freopen("in.txt","r",stdin)#define write freopen("out.txt","w",stdout)const int inf = 0x3f3f3f3f;const i64 inf64 = 0x3f3f3f3f3f3f3f3fLL;const double oo = 10e9;const double eps = 10e-10;const double pi = acos(-1.0);const int maxn = 1011;int T;int n;i64 a[maxn];i64 ans;int main(){ cin>>T; while(T--) { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } if(n==1) { ans = a[n]%9; if(ans == 0) { ans = 9; } cout<<ans<<endl; continue; } else { ans = (a[n]+1)%9; for(int i=n-1;i>=2;i--) { ans*=a[i]; ans%=9; ans += 1; } ans *= a[1]; ans %= 9; if(ans==0) { ans = 9; } cout<<ans<<endl; } } return 0;}
- SGU 118
- sgu 118 Digital Root
- SGU 118 Digital Root
- SGU
- SGU
- SGU
- SGU
- SGU
- SGU
- (SGU
- SGU
- SGU
- SGU
- SGU
- SGU
- SGU
- SGU
- SGU 118 Digital Root(数论)
- v$session 中查找locking信息
- HTML5开发工具大盘点(附下载) (二)
- 间断和孤岛问题处理方法总结
- 企业建站系统 开源系统
- C#面向对象设计模式纵横谈:Bridge 桥接模式
- SGU 118
- VS2010中CTRL+F5窗口也是一闪而过的解决办法
- strlen()函数
- oracle闪回
- 再说C++模板类的一些使用技巧
- oracle的闪回
- 黑马程序员-线程和socket
- fput(); fgetc();
- <<Windows CE 系统进程外组件应用开发 >> 文章的解读