- 博客(7)
- 资源 (1)
- 问答 (1)
- 收藏
- 关注
原创 如何利用一条简单语句判断一个整数是否为2的整数次幂
在写代码的过程中可能会遇到判断一个整数是否为2的整数次幂的问题,除了枚举的方法,还可以利用二进制的知识进行简单快速判断。2的整数次幂用二进制表示只存在一个1和n个0,因此,我们利用位运算&判断一个整数a与a-1的&是否为0即可。具体代码如下。代码非常简洁。#include<bits/stdc++.h>using namespace std;type...
2019-03-20 11:27:32 564
原创 CF 938A WordCorrection
A. Word CorrectionVictor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.Victor thinks that if a word contains two consecuti...
2018-02-17 22:41:37 945
原创 CF 939A Love Triangle
A. Love TriangleAs you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, numbered from 1 to n, and the plane with...
2018-02-17 22:31:23 389
原创 CF Text Volume
Text Volume题目:You are given a text of single-space separated words, consisting of small and capital Latin letters.Volume of the word is number of capital letters in the word. Volume of the text is max...
2018-02-17 11:05:39 451
原创 CF463 A题Palindromic Supersequence
Palindromic Supersequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string A. Find a string B, where B is a palindrome and A ...
2018-02-16 00:51:22 462
原创 write a String class by c++(study for c++)
class-Stringwrite a String class by c++自己定义一个字符串类String,使该类实现如下要求:String a=”Hello”;//重载=String b=a,c;//拷贝构造函数 c=b;//重载=String d=”world”; d+=a;重载+=b=a+d;//重载+bool f=a>d;//重载+String e=a.touppe...
2018-02-14 13:20:40 271
原创 基本单链表操作
#include#include#define N 10typedef struct sl{ int s; struct sl *next;}ss;ss *creat(int *s){ int i=1; ss *p,*q,*h; h=p=(ss*)malloc(sizeof(ss)); p->s=s[0];
2017-09-03 09:26:50 266
TA创建的收藏夹 TA关注的收藏夹
TA关注的人