1152 Google Recruitment

多年不练截取string用substr都忘了,还有要记住最后是要输出整一条string,比如,应该0023,而不是23,一开始一直不对。。。

#include <iostream>
#include <stdlib.h>
#include <string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int isprime(int k) {
    int result = 0;
    if (k == 1) {
        result = 1;
    }

    for (int i = 2; i < sqrt(k); i++) {
        if (k%i == 0) {
            result = 1;
            break;
        }
    }
    return result;
}

int main() {

    int l, n;
    string s;
    cin >> l >> n;
    cin >> s;
    string result = "404";
    for (int i = 0; i < l - n + 1; i++) {
        string k = s.substr(i, n);
        int t = stoi(k);

        if (isprime(t) == 0) {
            result = k;
            break;
        }
    }
    cout << result;
    system("pause");
};

原文地址:https://www.cnblogs.com/wsggb123/p/10205073.html

时间: 2024-10-20 18:34:21

1152 Google Recruitment的相关文章

1152 Google Recruitment (20 分)

1152 Google Recruitment (20 分) In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit prime found in conse

PAT Advanced 1152 Google Recruitment (20 分)

In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit prime found in consecutive digits of the natural co

PAT Advanced 1152 Google Recruitment (20分)

In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit prime found in consecutive digits of the natural co

A题目

1 1001 A+B Format(20) 2 1002 A+B for Polynomials(25) 3 1003 Emergency(25) 4 1004 Counting Leaves(30) 5 1005 Spell It Right(20) 6 1006 Sign In and Sign Out(25) 7 1007 Maximum Subsequence Sum(25) 8 1008 Elevator(20) 9 1009 Product of Polynomials(25) 10

PAT(甲级)2018年冬季考试

1152 Google Recruitment 思路:判断素数 #include<bits/stdc++.h> using namespace std; const int maxn = 1100; int a[maxn]; int n,k; long long getNum(int pos){ long long x = 0; for(int i=pos;i<=pos+k-1;i++){ x = x*10 + a[i]; } return x; } bool prime(long lo

分辨率验证工具 - 【Window Resizer】的使用 - Google扩展工具

# 今天在Firefox上面安装"The Addon Bar"未果,于是转战Google了 # 想说的是http://cn.bing.com/ 简直太好用了 软件名称:Window Resizer 安装地址:https://chrome.google.com/webstore/detail/window-resizer/kkelicaakdanhinjdeammmilcgefonfh 在Web浏览器范畴内,页面宽度有多种设计方式:页面宽度是960px.980px.1140px.1200px的页面

csharp:Google TTS API text to speech

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

国行手机安装GOOGLE PLAY

原文地址:http://blog.sina.com.cn/s/blog_68cff87b0101a96k.html 相信国行的手机都是没有google Play 功能的吧,相比其它国外的手机,功能上逊色不少. 而且国内软件市场比较复杂,偷窥隐私,安装木马,植入广告,耗费流量,这些都是国产软件的公开秘密! 所以想下载一些国外比较流行的软件,第3方软件市场又不安全,想一想还是用google的官方Google Play是最好的. 说干就干,前提是手机必须是root过,Root就是获得手机的最高权限,现

Google帝国研究——Google的产业构成

                                                                                    Google帝国研究--Google的产业构成 摘要:Google帝国研究  产业构成 作者:魏春颖 文章来源:网络整理 Google产业的构成: 1.    业务板块: 包括互联网搜索.云计算.广告技术,开发并提供大量基于互联网的产品与服务,开发线上软件.应用软件,还涉及移动设备的Android操作系统以及操作系统谷歌Chrom