题目网址:http://codeforces.com/contest/977/problem/A

题解:给你一个数n,进行k次变换,从末尾开始-1,512变成511,511变成510,510会把0消掉。(看Note应该都能看懂的吧~)

方法:水题。。。把数字用字符串读入,遇到末尾为0的情况就把字符串长度-1,不然就-1。然后len<=0的情况就输出0(不知道为什么不用<0就可以过了,可能不会出现这样的情况?),反之按长度一个个输出即可~

 #include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
#include<map>
#include<vector>
#include<set>
#include<queue>
using namespace std;
int main()
{
char n[];
int k;
cin >> n >> k;
int len = strlen(n);
while (k--)
{
if (n[len - ] == '')
{
len--;
}
else
{
n[len - ] -= ;
}
}
if (len == )
printf("0\n");
else
{
for (int i = ; i < len; i++)
{
printf("%c", n[i]);
}
printf("\n");
} return ;
}

Codeforces Round #479 (Div. 3) A. Wrong Subtraction的更多相关文章

  1. Codeforces Round #479 (Div. 3)解题报告

    题目链接: http://codeforces.com/contest/977 A. Wrong Subtraction 题意 给定一个数x,求n次操作输出.操作规则:10的倍数则除10,否则减1 直 ...

  2. Codeforces Round #479 (Div. 3) 题解 977A 977B 977C 977D 977E 977F

    A. Wrong Subtraction 题目大意:   定义一种运算,让你去模拟 题解:   模拟 #include <iostream> #include <cstdio> ...

  3. Codeforces Round #479 (Div. 3) C. Less or Equal

    题目地址:http://codeforces.com/contest/977/problem/C 题解:给一串数组,是否找到一个数x,找到k个数字<=x,找到输出x,不能输出-1.例如第二组,要 ...

  4. Codeforces Round #479 (Div. 3) F. Consecutive Subsequence (简单dp)

    题目:https://codeforces.com/problemset/problem/977/F 题意:一个序列,求最长单调递增子序列,但是有一个要求是中间差值都是1 思路:dp,O(n)复杂度, ...

  5. Codeforces Round #479 (Div. 3)题解

    CF首次推出div3给我这种辣鸡做,当然得写份博客纪念下 A. Wrong Subtraction time limit per test 1 second memory limit per test ...

  6. Codeforces Round #479 (Div. 3)

    手速场2333,这群人贼牛逼!手速贼快!   A. Wrong Subtraction time limit per test 1 second memory limit per test 256 m ...

  7. Codeforces Round #479 (Div. 3)解题代码

    A. Wrong Subtraction #include <bits/stdc++.h> using namespace std; int main() { int n,k; cin&g ...

  8. Codeforces Round #479 (Div. 3) B. Two-gram

    原题代码:http://codeforces.com/contest/977/problem/B 题解:有n个字符组成的字符串,输出出现次数两个字符组合.例如第二组样例ZZ出现了两次. 方法:比较无脑 ...

  9. E. Cyclic Components (DFS)(Codeforces Round #479 (Div. 3))

    #include <bits/stdc++.h> using namespace std; *1e5+; vector<int>p[maxn]; vector<int&g ...

随机推荐

  1. 【shell脚本】nginx每天自动切割日志脚本

    nginx每天日志量比较大的时候,最好每天自动切割,存储,这样可以方面以后的查询和分析 #!/bin/sh ################### #filename: nginx_log_rotat ...

  2. Web开发的发展史

    英文出处:arunr.欢迎加入翻译小组. 导读:Arunr 把过去 15 年以来,Web开发从最初的纯 HTML 到 CGI.PHP\JSP\ASP.Ajax.Rails.NodeJS 这个过程简要地 ...

  3. ADO.NET之Parameter属性

    在ADO.NET中, public SqlParameterCollection Parameters {get;}会得到一个SqlParameter属性.下面通过一个例子进行详细的认识吧. //例如 ...

  4. 使用js动态添加组件

    在文章开始之前,我想说两点 1 自己初学js,文章的内容在大神看来可能就是不值一提,但是谁都是从hello world来的,望高   手不吝指教# 2 我知道这个标题起的比较蛋疼,大家看图就能说明问题 ...

  5. cocos2d-x初探

    今天把cocos2d-x下载下来装了准备试试. 就不用windows本了,主要想做iOS游戏,所以这里用mac. 先在http://cocos2d-x.org/download下载右边的cocos,然 ...

  6. 类装载器DexClassLoader (android内核剖析)

    在java环境中,有个概念叫做"类装载器",其作用是动态装载Class文件.标准的java SDK中有一个ClassLoader类,借助它可以装载 想要的Class文件,每个Cla ...

  7. 多态&nbsp;OC——第十天

    1.多态  父类指针指向子类对象      没有继承就没有多态      联系前面知识才能清楚什么是多态,所以放到最后面总结小知识点,有前面的知识会对多态更好的了解,会觉得简单很多,但是看此篇博文需要 ...

  8. python的read() 、readline()、readlines()、xreadlines()

    先来一个小例子: import sys dir= os.path.dirname(os.path.abspath(__file__)) file_path='%s/test.txt'  % dir f ...

  9. (NO.00001)iOS游戏SpeedBoy Lite成形记(十一)

    之前的10篇内容主要实现了选手从起点移动至终点的动作,比较随机的模拟了选手的速度变化,另外完成了选手到达终点时该做的事情. 接下来的几篇中我们进一步完善SpeedBoy Lite项目,使它真正成为一个 ...

  10. git中failed to push some refs to git问题解决及基本使用

    国庆归来准备试用一下git,在提交代码时遇到时遇到一些问题 提交时使用git push origin master 出现failed to push some refs to git 回想一下,创建该 ...