题意:

给你一串数,问你如题。

思路:

我不是这样的作法,从后往前,先取00,再算%3==0的个数,往前推的时候有递推关系:

 #define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>//sprintf islower isupper
#include <cstdlib>//malloc exit strcat itoa system("cls")
#include <iostream>//pair
#include <fstream>
#include <bitset>
//#include <map>
//#include<unordered_map>
#include <vector>
#include <stack>
#include <set>
#include <string.h>//strstr substr
#include <string>
#include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
#include <cmath>
#include <deque>
#include <queue>//priority_queue<long long, vector<long long>, greater<long long> > q;//less
#include <vector>//emplace_back
//#include <math.h>
//#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
#include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
#define fo(a,b,c) for(register long long a=b;a<=c;++a)
#define fr(a,b,c) for(register long long a=b;a>=c;--a)
#define mem(a,b) memset(a,b,sizeof(a))
#define pr printf
#define sc scanf
void swapp(long long &a,long long &b);
double fabss(double a);
long long maxx(long long a,long long b);
long long minn(long long a,long long b);
long long Del_bit_1(long long n);
long long lowbit(long long n);
long long abss(long long a);
//const long long INF=(1LL<<60);
const double E=2.718281828;
const double PI=acos(-1.0);
const long long inf=(<<);
const double ESP=1e-;
const long long mod=(long long)1e9+;
const long long N=(long long)1e6+; char s[N];
long long ans=; int main()
{
sc("%s",s+);
s[]='&';
long long l=strlen(s)-;
long long cont=;
long long cnt[]={,,,},temp=;
fr(i,l,)
{
temp+=s[i]-'';
temp%=;
cnt[temp]++;
if(s[i]=='')
cont++;
}
fr(i,l,)
{
if(s[i]==s[i+]&&s[i]=='')
ans+=cnt[];
temp=s[i]-'';
temp%=;
if(temp==)
cnt[]--;
else if(temp==)
{
long long a=cnt[],b=cnt[],c=cnt[];
cnt[]=b-;cnt[]=a,cnt[]=c;
}
else
{
long long a=cnt[],b=cnt[],c=cnt[];
cnt[]=a-,cnt[]=c,cnt[]=b;
}
} pr("%lld\n",ans+cont);
return ;
} /**************************************************************************************/ long long maxx(long long a,long long b)
{
return a>b?a:b;
} void swapp(long long &a,long long &b)
{
a^=b^=a^=b;
} long long lowbit(long long n)
{
return n&(-n);
} long long Del_bit_1(long long n)
{
return n&(n-);
} long long abss(long long a)
{
return a>?a:-a;
} double fabss(double a)
{
return a>?a:-a;
} long long minn(long long a,long long b)
{
return a<b?a:b;
}

%300为0的个数(牛客第四场)-- number的更多相关文章

  1. 3的倍数 或运算构造x(牛客第四场)-- triples I

    题意: 给你一个数,希望你能用最少的3的倍数或运算成它,让你输出答案. 思路: 进制%3有规律,1.2.4.8.16%3是1.2.1.2.1 ... 利用这一点分情况取一些位合成一些数就是答案了. # ...

  2. 分层最短路(牛客第四场)-- free

    题意: 给你边权,起点和终点,有k次机会把某条路变为0,问你最短路是多长. 思路: 分层最短路模板题.题目有点坑(卡掉了SPFA,只能用dijkstra跑的算法). #include<iostr ...

  3. 笛卡尔树--牛客第四场(sequence)

    思路: O(n)建一颗笛卡尔树,再O(n)dfs向上合并答案就行了. #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #include &l ...

  4. 线性基求交(线段树)--牛客第四场(xor)

    题意: 给你n个基,q个询问,每个询问问你能不能 l~r 的所有基都能表示 x . 思路: 建一颗线性基的线段树,up就是求交的过程,按照线段树区间查询的方法进行check就可以了. #define ...

  5. 最短meeting路线(树的直径)--牛客第四场(meeting)

    题意: 给你一棵树,树上有些点是有人的,问你选一个点,最短的(最远的那个人的距离)是多少. 思路: 其实就是树的直径,两遍dfs,dfs第二遍的时候遇到人就更新直径就行了,ans是/2,奇数的话+1. ...

  6. 最小的K个数 牛客网 剑指Offer

    最小的K个数 牛客网 剑指Offer 题目描述 输入n个整数,找出其中最小的K个数.例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,. class Solution ...

  7. 第K个数 牛客网 程序员面试金典 C++ Python

    第K个数 牛客网 程序员面试金典 C++ Python 题目描述 有一些数的素因子只有3.5.7,请设计一个算法,找出其中的第k个数. 给定一个数int k,请返回第k个数.保证k小于等于100. 测 ...

  8. 牛客网第一场 A Monotonic Matrix

    链接:https://www.nowcoder.com/acm/contest/139/A来源:牛客网 Count the number of n x m matrices A satisfying ...

  9. 牛客第四次多校Maximum Mode

    链接:https://www.nowcoder.com/acm/contest/142/G来源:牛客网 题目描述 The mode of an integer sequence is the valu ...

随机推荐

  1. Sql Server 基本使用

    一.登录sql server数据库 1.若需要连接本机数据库服务器,服务器名可以采用“local”.“.”“本机Ip”. 2.在连接sql server 之前,确保sql server服务已经启动,如 ...

  2. 编写批处理使用msbuild编译项目

    echo off ::请把此bat脚本放到以下代码路径下 并在环境变量中配置对应版本的vs编译器的值 ::vs2017如:C:\Program Files (x86)\Microsoft Visual ...

  3. Spring Boot教程(三十三)使用Redis数据库(1)

    Spring Boot中除了对常用的关系型数据库提供了优秀的自动化支持之外,对于很多NoSQL数据库一样提供了自动化配置的支持,包括:Redis, MongoDB, Elasticsearch, So ...

  4. JavaWeb_(Struts2框架)拦截器interceptor

    此系列博文基于同一个项目已上传至github 传送门 JavaWeb_(Struts2框架)Struts创建Action的三种方式 传送门 JavaWeb_(Struts2框架)struts.xml核 ...

  5. Selenium 的页面加载以及几种等待的问题

    1. PageLoadStrategy : 当调用driver.get("https://xxxx.xxx.xxx")来访问某页面时,get方法通常会阻塞浏览器直到页面完全加载后才 ...

  6. Linux sssd 进程 ldap 客户端配置

    Linux sssd 进程 ldap 客户端配置 标签(空格分隔): ldap authconfig authconfig命令解析:authconfig 面对多计算机的身份管理以及账户信息同步, 其解 ...

  7. Java写入的常用技巧

    一.批量写入 Java写入大量数据到磁盘/数据库等其它第三方介质时,由于IO是比较耗费资源的操作,通常采用攒一批然后批量写入的模式 //通常构造一个缓存池,一个限制指标,可以是内存大小也可以是时间 B ...

  8. EasyUI中对于Grid的隐藏与显示

    $('#div_Grid').datagrid('hideColumn', 'mtnDate'); $('#div_Grid').datagrid('showColumn', 'mtnDate');

  9. [drf]访问文档出现错误'AutoSchema' object has no attribute 'get_link'

    报错 'AutoSchema' object has no attribute 'get_link' 解决 参考 REST_FRAMEWORK = { 'DEFAULT_SCHEMA_CLASS': ...

  10. GitHub-Tech-DotNet:Cnblogs

    ylbtech-GitHub-Tech-DotNet:Cnblogs 1.返回顶部 · EnyimMemcachedCore Forked from enyim/EnyimMemcached A Me ...