使用了C语言,小数据文件提交通过。

#include<stdio.h> #include<stdlib.h> #include<string.h> #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<unistd.h> #include<errno.h> #define BUFSIZE 256 char D2B(int K) { unsigned char temp = 0x00;; char quotient = K; char mod = 0; int i = 0; //printf("Kinit:%d/n",K); while (quotient != 0) { mod = quotient % 2; if (mod == 1) { temp = temp >> 1; temp = temp | 0x80; //printf("Ked1:%02x/n",temp); } else { temp = temp >> 1; temp = temp & 0x7f; //printf("Ked0:%02x/n",temp); } quotient = quotient / 2; //printf("King:%d/n",quotient); i++; } while (i != 8) { temp = temp >> 1; i++; } //printf("K:%02x/n",temp); return temp; } int GetLen(char K) { int temp = 0; int i; for (i = 0; i < 8; i++) { if (K & 1<<i) { temp ++; } else { break; } } //printf("len:%d/n",temp); return temp; } int main(int argc , char *argv[]) { FILE *fd; char buf[256]={'/0'}; int T, N, K; int i; if (argc != 2) { fprintf(stderr,"Usage: ./a.out A-small-practice.in/n"); return 0; } fd = fopen(argv[1], "r"); if (fd == NULL) { perror("Open file failed./n"); return 0; } fgets(buf, BUFSIZE, fd); sscanf(buf,"%d/n",&T); memset(buf, '/0', BUFSIZE); //printf("T:%d/n",T); #if 1 i = 1; while( i<=T ) { fgets(buf, BUFSIZE, fd); sscanf(buf, "%d %d/n", &N, &K); //printf("%d %d/n",N, K); //D2B(K); if ( GetLen(D2B(K)) >= N ) { //printf("%d %d/n",N, K); printf("Case #%d: ON/n",i); } else { printf("Case #%d: OFF/n",i); } memset(buf, '/0', BUFSIZE); i++; } #endif fclose(fd); }

Problem A. Snapper Chain 问题A.按扣链条 解决办法相关推荐

  1. 【Git】SSL certificate problem: unable to get local issuer certificate错误的解决办法

    问题描述 unable to access 'https://*****.git/': SSL certificate problem: unable to get local issuer cert ...

  2. CentOS 7 出现 a problem has occured and the system can‘t recover 解决办法

    1. 起因 自己的vm虚拟机Centos系统,今早启动出现"a problem has occured and the system can't recover"情况,具体如图: ...

  3. E: dpkg was interrupted, you must manually run ‘dpkg –configure -a’ to correct the problem. 解决办法

    E: dpkg was interrupted, you must manually run 'dpkg –configure -a' to correct the problem. 解决办法: su ...

  4. 计算机组装bios的密码破解,主板BIOS密码忘记了怎么清除?主板bios密码忘记了扣电池解决方法...

    有些用户为了电脑的安全性可能会设置BIOS密码,但是久而久之密码就会忘记掉,怎么想也想不到密码了,这是一个很常见的问题,以为小编经常QQ密码都会忘记,那么遇到这个问题,基本都是将主板BIOS恢复出厂复 ...

  5. SSL certificate problem: unable to get local issuer certificate解决办法

    在github上用https克隆代码时报了如下错误 fatal: unable to access 'https://github.com/xiaogao67/gin-cloud-storage.gi ...

  6. ImportError: HDFStore requires PyTables, No module named 'tables' problem importing解决办法

    在python中,使用HDF5时,windows环境下,可能会遇到如下报错: "ImportError: HDFStore requires PyTables, "No modul ...

  7. but MDK-ARM V5 Project genera have a problem 解决办法之一

    but MDK-ARM V5 Project genera have a problem 解决办法之一** 先说解决办法,如果安装了JAVA JDK,.卸载. 始末: Win10 64位.联想预装系统 ...

  8. 力扣报错“AddressSanitizer: heap-buffer-overflow on address...”的解决办法

    做力扣报了个错: AddressSanitizer: heap-buffer-overflow on address 0x6020000001cc at pc-- 大概意思 LeetCode使用了Ad ...

  9. Android studio中打包生成release版本时提示 A problem occurred evaluating root project ‘My‘出错问题的解决方法

    在Android studio中打包生成release版本时,下面的build output 提示 :   A problem occurred evaluating root project 'My ...

  10. PostgreSQL:Problem running post-install step. The database cluster initialisation failed. 解决方法。

    安装PG时报上述错误. 网上搜索出许多解决方案比较常见的有:字符集,用户权限,等等.均已排除,而且因为很容易搜到,所以不再赘述.我遇到的问题,最先发现的解决方法是:只要使用缺省的程序目录和数据目录就一 ...

最新文章

  1. php display_errors
  2. vb 实现二维数组(矩阵)转置。_笃学不倦|数组的定义
  3. 高并发编程-Daemon Thread的创建以及使用场景分析
  4. 线段树练习——区间合并
  5. 代码夹带是洪水猛兽吗?
  6. Java+大数据开发——HDFS详解
  7. 慢速HTTP拒绝服务攻击
  8. linux 普通用户间切换,Linux中管理员用户与普通用户之间的切换
  9. 白中英 计算机组成原理_计算机组成原理 第五版.立体化教材 白中英 大学教材...
  10. 如何编写代码解决问题,初学者指南
  11. Headless CMS 的内部
  12. 个性化推荐的另一种思路: 学习用户行为的解纠缠表示
  13. Trick 一题多解——交换两个数(swap)
  14. HTML如何实现简单登录页面
  15. 十进制和二进制如何换算?
  16. 机器学习 - SVD
  17. mysql修改字段设置_在mysql中,如何改变列声明.
  18. toupper() 函数
  19. 如何用百度搜索云盘分享的资料
  20. 第10章 对文件的输入输出

热门文章

  1. 输出三角形,平行四边形,菱形
  2. java使用egl_EGL 作用及其使用
  3. SAS(十二)PROC步
  4. sublimetext的文件编码理解reopen/reload with encoding,set encoding,save with encoding, set file encoding to
  5. flex子项常见属性 跟携程网首页案例制作。
  6. java-net-php-python-springboot办公自动化系统计算机毕业设计程序
  7. 【思维导图】redis详解
  8. Offset commit failed with a retriable exception. You should retry committing the latest consumed off
  9. linux基础-自查
  10. 【LeetCode刷题-中等】2. 两数相加(python c++)