2016 ACM/ICPC Asia Regional Qingdao Online

 

 

5878:

 

I Count Two Three

 

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2218    Accepted Submission(s): 974

 

 

Problem Description

I will show you the most popular board game in the Shanghai Ingress Resistance Team.
It all started several months ago.
We found out the home address of the enlightened agent Icount2three and decided to draw him out.
Millions of missiles were detonated, but some of them failed.

After the event, we analysed the laws of failed attacks.
It's interesting that the i-th attacks failed if and only if i can be rewritten as the form of 2a3b5c7d which a,b,c,d are non-negative integers.

At recent dinner parties, we call the integers with the form 2a3b5c7d "I Count Two Three Numbers".
A related board game with a given positive integer n from one agent, asks all participants the smallest "I Count Two Three Number" no smaller than n.

 

 

Input

The first line of input contains an integer t (1≤t≤500000), the number of test cases. t test cases follow. Each test case provides one integer n (1≤n≤109).

 

 

Output

For each test case, output one line with only one integer corresponding to the shortest "I Count Two Three Number" no smaller than n.

 

 

Sample Input

 

10 1 11 13 123 1234 12345 123456 1234567 12345678 123456789

 

 

Sample Output

 

1 12 14 125 1250 12348 123480 1234800 12348000 123480000

 

 

Source

2016 ACM/ICPC Asia Regional Qingdao Online

 

 

 

 

水题,要求输出大于等于n的第一个满足因子只为2,3,5,7的数。

生成所有数,排序即可。

 

#include <cstdio>
#include <iostream>
#include <string.h>
#include <string> 
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stack>
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
const int maxn=100005,inf=0x3f3f3f3f;  
const ll llinf=0x3f3f3f3f3f3f3f3f;   
const ld pi=acos(-1.0L);
ll a[maxn]; 

int main() {
    int n,i;
    a[0]=1;
    ll d[4]={2,3,5,7};
    queue<ll> q;
    map<ll,int> mp;
    mp[1]=1;
    q.push(1);
    n=1;
    ll last=0,f;
    while (!q.empty()) {
        ll now=q.front();
        q.pop();
        for (i=0;i<4;i++) {
            if ((f=now*d[i])<=1e9) {
                if (!mp[f]) {
                    a[n++]=f;
                    q.push(f);
                    mp[f]=1;
                }
            } else last=min(last,f);
        }
    }
    a[n++]=last;
    sort(a,a+n);
    int cas;
    scanf("%d",&cas);
    while (cas--) {
        ll x,ans;
        scanf("%lld",&x);
        ans=lower_bound(a,a+n,x)-a;
        printf("%lld\n",a[ans]);
    }
    return 0;
}

 

 

 

 

 

 

5879:

 

Cure

 

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3553    Accepted Submission(s): 892

 

 

Problem Description

Given an integer n, we only want to know the sum of 1/k2 where k from 1 to n.

 

 

Input

There are multiple cases.
For each test case, there is a single line, containing a single positive integer n. 
The input file is at most 1M.

 

 

Output

The required sum, rounded to the fifth digits after the decimal point.

 

 

Sample Input

 

1 2 4 8 15

 

 

Sample Output

 

1.00000 1.25000 1.42361 1.52742 1.58044

 

 

Source

2016 ACM/ICPC Asia Regional Qingdao Online

 

 

 

 

 

水题。输入n,输出1~n的1/K^2的级数和。

数很大时结果是收敛的,直接输出结果即可。其他情况预处理之后O(1)输出

 

 

#include <cstdio>
#include <iostream>
#include <string.h>
#include <string> 
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <iomanip>
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
#define N 1000000
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
const int maxn=120005,inf=0x3f3f3f3f;  
const ll llinf=0x3f3f3f3f3f3f3f3f;   
const ld pi=acos(-1.0L);
ld sum[N+5];

int main() {
    ll i;
    sum[0]=0L;
    for (i=1;i<=N;i++) {
        sum[i]=sum[i-1]+1/(ld)(i*i);
    }
    ll n;
    ld ans=pi*pi/6.0L;
    string s;
    cout << setiosflags(ios::fixed) << setprecision(5);
    while (getline(cin,s)) {
        if (s.length()>=7) n=N; else {
            n=0;int len=s.length();
            for (i=0;i<len;i++) n=n*10+(s[i]-'0');
            if (n>N) n=N;
        }
        cout << sum[n] << endl;
    }
    return 0;
}

 

 

 

 

 

 

5880:

 

Family View

 

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2182    Accepted Submission(s): 473

 

 

Problem Description

Steam is a digital distribution platform developed by Valve Corporation offering digital rights management (DRM), multiplayer gaming and social networking services. A family view can help you to prevent your children access to some content which are not suitable for them. 

Take an MMORPG game as an example, given a sentence T, and a list of forbidden words {P}, your job is to use '*' to subsititute all the characters, which is a part of the substring matched with at least one forbidden word in the list (case-insensitive).

For example, T is: "I love Beijing's Tiananmen, the sun rises over Tiananmen. Our great leader Chairman Mao, he leades us marching on."

And {P} is: {"tiananmen", "eat"}

The result should be: "I love Beijing's *********, the sun rises over *********. Our gr*** leader Chairman Mao, he leades us marching on."

 

 

Input

The first line contains the number of test cases. For each test case:
The first line contains an integer n, represneting the size of the forbidden words list P. Each line of the next n lines contains a forbidden words Pi (1≤|Pi|≤1000000,∑|Pi|≤1000000) where Pi only contains lowercase letters.

The last line contains a string T (|T|≤1000000).

 

 

Output

For each case output the sentence in a line.

 

 

Sample Input

 

1 3 trump ri o Donald John Trump (born June 14, 1946) is an American businessman, television personality, author, politician, and the Republican Party nominee for President of the United States in the 2016 election. He is chairman of The Trump Organization, which is the principal holding company for his real estate ventures and other business interests.

 

 

Sample Output

 

D*nald J*hn ***** (b*rn June 14, 1946) is an Ame**can businessman, televisi*n pers*nality, auth*r, p*litician, and the Republican Party n*minee f*r President *f the United States in the 2016 electi*n. He is chairman *f The *

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值