c语言实现:4和7幸运数字的题
#include <stdio.h>
#include <math.h>
#include <vector> using namespace std; int main()
{
int i; int x,y,z;
char *p;
double w=;
int temp;
char ch; vector<int> vec1; vector<unsigned int> vec2; vector<int> vec3; scanf("%d",&i); for(x=;x<i;x++)
{
scanf("%d",&temp);
vec1.push_back(temp);
}
for(x=;x<i;x++)
{
for(y=;y<;y++)
{
if((pow(w,y)-)*>=vec1[x] && (pow(w,y-)-)*<=vec1[x])
break;
}
vec2.push_back(y);
} for(x=;x<i;x++)
{
vec3.push_back(vec1[x]-*(pow(w,y-)-)-1);
} for(x=;x<i;x++)
{
//内存的管理问题
p = (char*)malloc(sizeof(char)*(vec2[x]+1));
memset(p,,vec2[x]+1); for(y=;y<vec2[x];y++)
{
if(vec3[x]&0x1==) p[y]=+'';
else p[y]=+''; vec3[x] = vec3[x]>>;
}
for(y=,z=vec2[x]-;y<vec2[x]/;y++,z--)
{
ch = p[y];
p[y]= p[z];
p[z]=ch;
}
printf("%s\n",p); }
}
c语言实现:4和7幸运数字的题的更多相关文章
- 2014.11.12模拟赛【美妙的数字】| vijos1904学姐的幸运数字
美妙的数字(number.c/.cpp/.pas) 题目描述 黄巨大认为非负整数是美妙的,并且它的数值越小就越美妙.当然0是最美妙的啦. 现在他得到一串非负整数,对于每个数都可以选择先对它做二进制非运 ...
- BZOJ 1853 【Scoi2010】 幸运数字
Description 在中国,很多人都把6和8视为是幸运数字!lxhgww也这样认 为,于是他定义自己的"幸运号码"是十进制表示中只包含数字6和8的那些号码,比如68,666,8 ...
- BZOJ 4568 幸运数字
题目传送门 4568: [Scoi2016]幸运数字 Time Limit: 60 Sec Memory Limit: 256 MB Description A 国共有 n 座城市,这些城市由 n-1 ...
- BZOJ 1853: [Scoi2010]幸运数字
1853: [Scoi2010]幸运数字 Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 2117 Solved: 779[Submit][Status] ...
- 【BZOJ-4568】幸运数字 树链剖分 + 线性基合并
4568: [Scoi2016]幸运数字 Time Limit: 60 Sec Memory Limit: 256 MBSubmit: 238 Solved: 113[Submit][Status ...
- 【BZOJ-1853&2393】幸运数字&Cirno的完美算数教室 容斥原理 + 爆搜 + 剪枝
1853: [Scoi2010]幸运数字 Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 1817 Solved: 665[Submit][Status] ...
- BZOJ1853 [Scoi2010]幸运数字
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000作者博客:http://www.cnblogs.com/ljh2000-jump/转 ...
- 【bzoj1853】 Scoi2010—幸运数字
http://www.lydsy.com/JudgeOnline/problem.php?id=1853 (题目链接) 今天考试考了容斥,结果空知道结论却不会写→_→ 题意 求区间中不含6,8两个数字 ...
- 幸运数字(number)
幸运数字(number) Time Limit:1000ms Memory Limit:64MB [题目描述] LYK最近运气很差,例如在NOIP初赛中仅仅考了90分,刚刚卡进复赛,于是它决定使用 ...
随机推荐
- trate
from sklearn.feature_extraction.text import CountVectorizer from sklearn.feature_extraction.text imp ...
- 详细理解 > /dev/null 2>&1
0:表示键盘输入(stdin) 1:表示标准输出(stdout),系统默认是1 2:表示错误输出(stderr) "command >/dev/null 2>&1 &am ...
- elisp语法
http://stackoverflow.com/questions/3855862/setq-and-defvar-in-lisp defvar, let, setq的语法分析: defvar in ...
- IIS中使用PUT方法錯誤記錄
在IIS7.5中使用PUT,DELETE方法時會遇到404,405錯誤,特記錄解決辦法:404: 405: 在web.config的system.webServer節點中加入 <modules ...
- BPL插件框架的二种实现
1)非RTTI方式适用于所有的DELPHI版本 unit untMain; interface uses Windows, Messages, SysUtils, Classes, Graphics, ...
- DATASNAP为支持FIREDAC而增加的远程方法的数据类型TFDJSONDataSets
前面的博客提到用FIREDAC全面替代COM那一套东西:DATAPROVIDER,OLEVARIANT,CLIENTDATASET,DBEXPRESS... 显然,DATASNAP的远程方法必须增加对 ...
- HDU1856More is better(并查集)
最近发现以前的东西都忘得差不多了,在这里刷刷水题 并查集: int find_parent(int x) { return x = p[x] ? x : p[x] = find_parent(p[x] ...
- FORTRAN程序设计权威指南
<FORTRAN程序设计权威指南> 基本信息 作者: 白海波 出版社:机械工业出版社 ISBN:9787111421146 上架时间:2013-7-23 出版日期:2013 年7月 ...
- Java常用类(String、StringBuffer、Math、Arrays)
1.String 操作对象时会重新分配堆内存,栈内存的引用会重新指向新的堆内存 2.StringBuffer(字符串缓存区) 操作的对象一直都是一个 3.Math Math.max(xx,xx); M ...
- 让人眼花缭乱的 RSS 版本0.90、0.91、0.92、0.93、0.94、1.0 和 2.0
1.0的规范 http://web.resource.org/rss/1.0/spec 2.0的规范 http://cyber.law.harvard.edu/rss/rss.html 一个介绍什么是 ...