zoukankan      html  css  js  c++  java
  • Round #411 (Div.2)

    A. Fake NP
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.

    You are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times.

    Solve the problem to show that it's not a NP problem.

     
    Input

    The first line contains two integers l and r (2 ≤ l ≤ r ≤ 109).

     
    Output

    Print single integer, the integer that appears maximum number of times in the divisors.

    If there are multiple answers, print any of them.

     
    Examples
     
    Input
    19 29
     
    Output
    2
     
    Input
    3 6
     
    Output
    3
     
    Note

    Definition of a divisor: https://www.mathsisfun.com/definitions/divisor-of-an-integer-.html

    The first example: from 19 to 29 these numbers are divisible by 2: {20, 22, 24, 26, 28}.

    The second example: from 3 to 6 these numbers are divisible by 3: {3, 6}.

    题意:求因子

    1 #include <bits/stdc++.h>
    2 using namespace std;
    3 int main(){  
    4     int l,r;
    5     scanf("%d%d",&l,&r);
    6     if(l==r) printf("%d
    ",l);
    7     else printf("2
    ");      
    8 
    9 } 
    D. Minimum number of steps
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the minimum number of steps we should perform to make our job done modulo 109 + 7.

    The string "ab" appears as a substring if there is a letter 'b' right after the letter 'a' somewhere in the string.

     
    Input

    The first line contains the initial string consisting of letters 'a' and 'b' only with length from 1 to 106.

     
    Output

    Print the minimum number of steps modulo 109 + 7.

     
    Examples
    Input
    ab
     
    Output
    1
     
    Input
    aab
    Output
    3
     
    Note

    The first example: "ab"  →  "bba".

    The second example: "aab"  →  "abba"  →  "bbaba"  →  "bbbbaa".

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 const int mod=1e9+7;
     4 int main(){
     5     string s;
     6     cin>>s;
     7     int ans=0;
     8     int t=0;
     9     for(int i=s.length()-1;i>=0;i--){
    10         if(s[i]=='b')
    11             t=(t+1)%mod;
    12         else {
    13         ans=(ans+t)%mod;
    14         t=(t*2)%mod;
    15         }
    16     }
    17     cout<<ans<<endl;
    18     return 0;
    19 }
  • 相关阅读:
    北极星杯 awd复现
    5,linux入门到上手-文件与文件系统的压缩,打包与备份
    4,linux入门到上手-文件与目录相关操作
    ctf中 preg_match 绕过技术 | 无字母数字的webshell
    巅峰极客 2019部分题解 writeup
    使用python爬去中国最好大学排名2016年
    python进制转换
    python应用-爬取猫眼电影top100
    3,linux入门到上手-文件权限管理与配置
    DNS、域、域名及FQDN 概念
  • 原文地址:https://www.cnblogs.com/z-712/p/7544235.html
Copyright © 2011-2022 走看看