tjut 5912
来源:互联网 发布:灰姑娘网络语什么意思 编辑:程序博客网 时间:2024/05/27 20:33
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<climits> #include<string> #include<queue> #include<stack> #include<set> #include<map> #include<algorithm> using namespace std; #define rep(i,j,k)for(i=j;i<k;i++) #define per(i,j,k)for(i=j;i>k;i--) #define MS(x,y)memset(x,y,sizeof(x)) #define max(a,b) a>b?a:b #define min(a,b) a<b?a:b #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 typedef long long LL; const int INF=0x7ffffff; const int M=100+1; int a[M],b[M]; int i,j,k,n,m; int fz,fm; int gcd(int x,int y) { return y?gcd(y,x%y):x; } int main() { int T; scanf("%d",&T); int Case=1; while(T--){ scanf("%d",&n); for(i=1;i<=n;i++)scanf("%d",&a[i]); for(i=1;i<=n;i++)scanf("%d",&b[i]); int fz=b[n],fm=a[n]; for(i=n-1;i;i--){ fz+=a[i]*fm; fm*=b[i]; swap(fz,fm); } int t=gcd(fz,fm); printf("Case #%d: %d %d\n",Case++,fz/t,fm/t); } return 0; }
0 0
- tjut 5912
- tjut 5289
- tjut 5288
- tjut 5294
- tjut 2586
- tjut 5296
- tjut 5297
- tjut 5299
- tjut 5384
- tjut 5387
- tjut 5386
- tjut 5381
- tjut 5400
- tjut 5399
- tjut 5396
- tjut 5398
- tjut 5412
- tjut 5410
- D3D11教程三十二之MultipleLightShadowMapping
- python爬虫小项目:爬取糗事百科段子
- Android6.0-新控件(二)
- jsonP自学
- 网络框架之Retrofit详细讲解《一》
- tjut 5912
- javax.mail.AuthenticationFailedException: 530 Error: A secure connection is requiered
- ubuntu 安装和命令收集
- Struts2对EL的改变和OGNL
- 【49.23%】【hdu 1828】Picture
- 2016年Java面试题整理
- NOIP 2015模拟赛[nodgd题]题解&总结
- HDU 2602 Bone Collector(简单01背包)
- B. Memory and Trident