• cf490 C. Hacking Cypher(无语)


    http://codeforces.com/contest/490/problem/C

    表示我考场上犯逗。。

    这个拆成霍纳边乘边mod即可。。

    为毛我考场胡思乱想?

    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <string>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    using namespace std;
    typedef long long ll;
    #define rep(i, n) for(int i=0; i<(n); ++i)
    #define for1(i,a,n) for(int i=(a);i<=(n);++i)
    #define for2(i,a,n) for(int i=(a);i<(n);++i)
    #define for3(i,a,n) for(int i=(a);i>=(n);--i)
    #define for4(i,a,n) for(int i=(a);i>(n);--i)
    #define CC(i,a) memset(i,(a),sizeof(i))
    #define read(a) a=getint()
    #define print(a) printf("%d", a)
    #define dbg(x) cout << (#x) << " = " << (x) << endl
    #define printarr2(a, b, c) for1(_, 1, b) { for1(__, 1, c) cout << a[_][__]; cout << endl; }
    #define printarr1(a, b) for1(_, 1, b) cout << a[_] << '	'; cout << endl
    inline const ll getint() { ll r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
    inline const int max(const int &a, const int &b) { return a>b?a:b; }
    inline const int min(const int &a, const int &b) { return a<b?a:b; }
    
    const int N=1e6+5;
    char s[N];
    bool ok[N];
    int n;
    long long a, b;
    
    int main() {
    	scanf("%s", s+1);
    	n=strlen(s+1);
    	read(a); read(b);
    	int pos=-1;
    	ll k=0, p=1;
    	for3(i, n, 1) {
    		k=(k+(ll)(s[i]-'0')*p)%b;
    		p=(p*10)%b;
    		if(s[i]-'0'==0) continue;
    		if(k==0) ok[i]=1;
    	}
    	k=0;
    	for1(i, 1, n-1) {
    		k=(k*10+s[i]-'0')%a;
    		if(k==0 && ok[i+1]==1) {
    			pos=i;
    			break;
    		}
    	}
    	if(pos==-1) { puts("NO"); return 0; }
    	puts("YES");
    	for1(i, 1, pos) putchar(s[i]); puts("");
    	for1(i, pos+1, n) putchar(s[i]);
    	return 0;
    }
    

      

  • 相关阅读:
    golang实现并发爬虫一(单任务版本爬虫功能)
    golang实现rabbitmq的五种模式
    KNN笔记
    Observer Pattern
    关于data-属性
    Python中的装饰器
    Python中的高阶函数与匿名函数
    Python中的列表生成式和多层表达式
    Thymeleaf读取国际化文本时出现??xxxxxx_zh_CN??问题
    Java8新特性(1):Lambda表达式
  • 原文地址:https://www.cnblogs.com/iwtwiioi/p/4117870.html
Copyright © 2020-2023  润新知