博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Deposits Gym - 100623D区间能整除的个数
阅读量:4204 次
发布时间:2019-05-26

本文共 2509 字,大约阅读时间需要 8 分钟。

Problem D. DepositsInput file: deposits.inOutput file: deposits.outTime limit: 3 secondsMemory limit: 256 megabytesFinancial crisis forced many central banks deposit large amounts of cash to accounts of investment andsavings banks in order to provide liquidity and save credit markets.Central bank of Flatland is planning to put n deposits to the market. Each deposit is characterized byits amount ai.The banks provide requests for deposits to the market. Currently there are m requests for deposits. Eachrequest is characterized by its length bi days.The regulations of Flatland’s market authorities require each deposit to be refinanced by equal integeramount each day. That means that a deposit with amount a and a request with length b match eachother if and only if a is divisible by b.Given information about deposits and requests, find the number of deposit-request pairs that match eachother.InputThe first line of the input file contains n — the number of deposits (1 ≤ n ≤ 100 000). The second linecontains n integer numbers: a1, a2, . . . , an (1 ≤ ai ≤ 106).The third line of the input file contains m — the number of requests (1 ≤ m ≤ 100 000). The forth linecontains m integer numbers: b1, b2, . . . , bm (1 ≤ bi ≤ 106).OutputOutput one number — the number of matching pairs.Exampledeposits.in deposits.out43 4 5 641 1 2 312The following pairs match each other: (3, 1) twice (as (a1, b1) and as (a1, b2)), (3, 3), (4, 1) twice, (4, 2),(5, 1) twice, (6, 1) twice, (6, 2), and (6, 3).
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;int a[1000005],b[1000005];int main(){ freopen("deposits.in","r",stdin); freopen("deposits.out","w",stdout); int n,m; scanf("%d",&n); int k; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(int i=0; i

////  main.cpp//  160929////  Created by 刘哲 on 17/4/6.//  Copyright © 2016年 my_code. All rights reserved.////#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define lowbit(x) (x&-x)using namespace std;const int MAXN = 1e6+10;long long a[MAXN],b[MAXN],x,ans,n,m;int main(){ freopen("deposits.in","r",stdin); freopen("deposits.out","w",stdout); while(cin>>n) { ans = 0; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(int i=0;i
>m; for(int i=0;i

转载地址:http://avali.baihongyu.com/

你可能感兴趣的文章
linux设置环境变量 临时设置 和 永久设置
查看>>
检查网站在世界各地的打开速度
查看>>
jquery 向上(顶部),向下(底部)滑动
查看>>
seo
查看>>
MySQL: InnoDB 还是 MyISAM?
查看>>
SQL语言的组成部分 ddl dcl dml
查看>>
mysql数据库从库同步延迟的问题
查看>>
1.mysql数据库主从复制部署笔记
查看>>
mysql数据库主从同步的问题解决方法
查看>>
mysql 配置 - on xFanxcy.com
查看>>
mysql一: 索引优化
查看>>
测试人员,今天再不懂BDD就晚了!
查看>>
害怕自动化(1)
查看>>
深圳市软件质量提升工程系列活动——安全测试百人大课堂
查看>>
LoadRunner如何在脚本运行时修改log设置选项?
查看>>
QC数据库表结构
查看>>
自动化测试工具的3个关键部分
查看>>
测试工具厂商的编程语言什么时候“退休”?
查看>>
资源监控工具 - Hyperic HQ
查看>>
LoadRunner中Concurrent与Simultaneous的区别
查看>>