• #69. 新年的QAQ


    题目描述

    http://uoj.ac/problem/69

    题解

    做之前瞄了先一眼题解,get到了核心部分

    因为给的运算符很不靠谱,所以考虑实现一个靠谱的运算符

    题解的"正常"做法是按照行号来编号,并不是很明白

    正常做法(自己写的):如果要实现c=a+b,那么搞一个d=c-a-b判断d是否为0来跳转即可,因为判断0的跳转是100%正确的,而且如果结果是错的但d=0的几率可以忽略不计,a%b同理

    于是就没了

    更加正常的做法:实现c=a+b,把运算做两次之后判断是否相等,给的逻辑运算符很辣鸡,所以直接用两次的差判断0即可

    code

    #include <bits/stdc++.h>
    #define fo(a,b,c) for (a=b; a<=c; a++)
    #define fd(a,b,c) for (a=b; a>=c; a--)
    #define ll long long
    //#define file
    using namespace std;
    
    int main()
    {
        #ifdef file
        freopen("prog.txt","w",stdout);
        #endif
        
        cout<<"input n"<<endl;
    	cout<<"input m"<<endl;
    	cout<<"a = 0"<<endl;
    	cout<<"b = 1"<<endl;
    	cout<<"c = a + b"<<endl;
    	cout<<"z = c - a"<<endl;
    	cout<<"z = z - b"<<endl;
    	cout<<"if z goto 5"<<endl;
    	cout<<"x = c % m"<<endl;
    	cout<<"y = c / m"<<endl;
    	cout<<"z = y * m"<<endl;
    	cout<<"z = z + x"<<endl;
    	cout<<"z = z - c"<<endl;
    	cout<<"if z goto 9"<<endl;
    	cout<<"c = x"<<endl;
    	cout<<"a = b"<<endl;
    	cout<<"b = c"<<endl;
    	cout<<"c = n - 1"<<endl;
    	cout<<"z = c + 1"<<endl;
    	cout<<"z = z - n"<<endl;
    	cout<<"if z goto 18"<<endl;
    	cout<<"n = c"<<endl;
    	cout<<"if n goto 5"<<endl;
    	cout<<"output a"<<endl;
    }
    
  • 相关阅读:
    Datediff的使用(统计本日,昨日,本周,本月)
    数据库之查询语句
    数据库之表关系
    数据库中的数据类型
    数据库概念和基本操作
    IO模型
    并发编程之协程
    GIL与多线程(线程池与进程池,同步异步阻塞非阻塞)
    并发编程之多线程
    并发编程之多进程
  • 原文地址:https://www.cnblogs.com/gmh77/p/13509945.html
Copyright © 2020-2023  润新知