最近经常刷到一个关于爱情的辩题:

“到底是从未在一起更遗憾;还是最终没有在一起更遗憾。”

我想以下这段文字是属于这个辩题最贴切的答案:

“如果知道爱情没有结局,给你机会重新来过,你会选择重蹈覆辙吗? 会 ,且一定会。正因为那段有她陪伴的时光,如今我不再偏执,不再任性,不再孩子气。在那段彼此为伴的日子里, 我们炙热善良,渴望的同时也在做着最浪漫的事情——一起慢慢变老,哪怕我庸庸碌碌太平常。我的意思是,金风玉露一相逢,便胜却人间无数,感謝她的出现。可是啊,哪份满分试卷在作答前不是空白的呢?

我承认定数,这世间风物辽阔,四海、四季,以及那冗杂的感情,各有旨趣。我将永远怀念、感谢过去的事情, 它改变了我的幼稚,填补了我的人生, 让我学会了与念妥协,周全日子。

感谢生活,有剥夺亦有馈赠, 可惜我并没有足够幸运 ,它仅赐我同行的缘分,却吝啬一起到老的勇气,可难道如果提前知道结局就会拒绝相遇吗?

我想,不会的。

什么是结局?天作之合结良缘是结局?永结同心成佳偶是结局?生娃带娃是结局?并骨同栖是结局?都不是,都他妈不是!那到底什么才是真理?什么才是结局?之死靡渝的相爱才是,相爱才是!是开始,也是结局。

如果这辈子就是我们上辈子说的下辈子,我还是会想在没有天气预报的雨天牵着你奔跑 ;还是会想在阳光灿烂的日子看着你傻笑;还是会想上一秒红着脸在争吵,下一秒转身就能和好;还是会想在能看到的未来里,有你。

欲买桂花同载酒,终不似,少年游。如果风吹八千里仍有归期;如果我还爱你;如果没有如果…

如果这就是爱情,I love you, I'm crazy. ”

love0 文章内容来源于知乎专栏: https://zhuanlan.zhihu.com/p/436063727 copyright: mignon@金曜日東ク84b https://www.pixiv.net/en/artworks/85601747

AP CSA Sorting Algorithms

没想到AP CSA居然也涉及排序的内容 本篇就分享几种基本的排序算法以及JAVA代码实现

Content:
  1. Bubble Sort
  2. Insert Sort
  3. Select Sort
  4. Quick Sort
  5. Bucket Sort

Bubble Sort

一种简单但是十分低效的算法。 在要排序的一组数中,对当前还未排好序的范围内的全部数,自上而下对相邻的两个数依次进行比较和调整,让较大的数往下沉,较小的往上冒。即:每当两相邻的数比较后发现它们的排序与排序要求相反时,就将它们互换。依次比较相邻的两个数,将小数放在前面,大数放在后面。即在第一轮比较中:首先比较第1个和第2个数,将小数放前,大数放后;然后比较第2个数和第3个数,将小数放前,大数放后,如此继续,直至比较最后两个数,将小数放前,大数放后。重复第一轮的步骤,直至全部排序完成。 如果能看到算法可视化的话,就可以看到小的数像气泡一样,一点一点的从下面浮上来,所以叫bubble sort,冒泡排序。

Java 实现:

import java.util.*;
public class BubbleSort{
    public static void main(String[] agrs){
        Scanner scan=new Scanner(System.in);
        System.out.println("Enter numbers of elements: ");
        int n=scan.nextInt();
        int[] a=new int[n+5];
        for(int i=0;i<n;i++){
            a[i]=scan.nextInt();
        }
        /*
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(a[i]>a[j]){
                    int ins=a[i];
                    a[i]=a[j];
                    a[j]=ins;
                }
            }
        }
        */
        for(int i=0;i<n;i++){
            for(int j=n-2;j>=i;j--){
                if(a[j]>a[j+1]){
                    int ins=a[j];
                    a[j]=a[j+1];
                    a[j+1]=ins;
                }
            }
        }
        for(int i=0;i<n;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println();
    }
}

Insert Sort

把待排序的纪录按其关键码值的大小逐个插入到一个已经排好序的有序序列中,直到所有的纪录插入完为止,得到一个新的有序序列


import java.util.*;
public class InsertSort{
    public static void main(String[] agrs){
        Scanner scan=new Scanner(System.in);
        System.out.println("Enter numbers of elements: ");
        int n=scan.nextInt();
        int[] a=new int[n+5];
        for(int i=0;i<n;i++){
            a[i]=scan.nextInt();
        }
        for(int i=0;i<n;i++){
            int std=a[i];
            int j;
            for(j=i-1;j>=0;j--){
                if(a[j]>std){
                    a[j+1]=a[j];
                }
                else{
                    break;
                }
            }
            a[j+1]=std;
        }
        for(int i=0;i<n;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println();
    }
}

Select Sort

在要排序的一组数中,选出最小的一个数与第一个位置的数交换;然后在剩下的数当中再找最小的与第二个位置的数交换,如此循环到倒数第二个数和最后一个数比较为止。

import java.util.*;
public class SelectSort{
    public static void main(String[] agrs){
        Scanner scan=new Scanner(System.in);
        System.out.println("Enter numbers of elements: ");
        int n=scan.nextInt();
        int[] a=new int[n+5];
        for(int i=0;i<n;i++){
            a[i]=scan.nextInt();
        }
        for(int i=0;i<n;i++){
            int flag=i;
            for(int j=i+1;j<n;j++){
                if(a[j]<a[flag]){
                    flag=j;
                }
            }
            int ins=a[i];
            a[i]=a[flag];
            a[flag]=ins;
        }
        for(int i=0;i<n;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println();
    }
}

Quick Sort

也就是常说的快速排序, 综合上来讲最快也是最好的排序算法之一,记住别爆栈。

基本思想:选择一个基准元素,通常选择第一个元素或者最后一个元素,通过一轮扫描,将待排序列分成两部分,一部分比基准元素小,一部分大于等于基准元素,此时基准元素在其排好序后的正确位置,然后再用同样的方法递归地排序划分的两部分,直到各区间只有一个数。

import java.util.*;
public class QuickSort{
    static int[] a=new int[10000000];
    public static void quickSort(int[] a, int left, int right){
        int std=a[left];
        int i=left,j=right;
        if(right<=left){
            return;
        }
        else{
            while(i<j){
                while(j>i&&a[j]>std){
                    j--;
                }
                if(i<j){
                    a[i]=a[j];  
                    i++;
                }
                while(i<j&&a[i]<=std){
                    i++;
                }
                if(i<j){
                    a[j]=a[i];
                    j--;
                }
            }
            a[i]=std;
            quickSort(a,left,i-1);
            quickSort(a,i+1,right);
        }
    }
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        System.out.println("Enter numbers of elements: ");
        int n=scan.nextInt();
        for(int i=0;i<n;i++){
            a[i]=scan.nextInt();
        }
        quickSort(a,0,n-1);
        for(int i=0;i<n;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println();
    }
}
Read more »

APCSA Lab

Content
  1. Square
  2. SquareTest
Square
import java.util.Scanner;

public class Square
{
    int[][] square;
    //--------------------------------------
    //create new square of given size
    //--------------------------------------
    public Square(int size)
    {
        square=new int[size][size];
    }

    //--------------------------------------
    //return the sum of the values in the given row
    //--------------------------------------
    public int sumRow(int row)
    {
        int sumR=0;
        for(int i=0;i<square.length;i++){
            sumR+=square[row][i];
        }
        return sumR;
    }

    //--------------------------------------
    //return the sum of the values in the given column
    //--------------------------------------
    public int sumCol(int col)
    {
        int sumC=0;
        for(int i=0;i<square.length;i++){
            sumC+=square[i][col];
        }
        return sumC;
    }

    //--------------------------------------
    //return the sum of the values in the main diagonal
    //--------------------------------------
    public int sumMainDiag()
    {
        int sumD1=0;
        for(int i=0;i<square.length;i++){
            sumD1+=square[i][i];
        }
        return sumD1;
    }

    //--------------------------------------
    //return the sum of the values in the other ("reverse") diagonal
    //--------------------------------------
    public int sumOtherDiag()
    {
        int sumD2=0;
        for(int i=0;i<square.length;i++){
            sumD2+=square[i][square.length-i-1];
        }
        return sumD2;
    }

    //--------------------------------------
    //return true if the square is magic (all rows, cols, and diags have
    //same sum), false otherwise
    //--------------------------------------
    public boolean magic()
    {
        int index=0;
        int[] test=new int[square.length*square.length+2];
        for(int i=0;i<square.length;i++){
            test[index]=sumRow(i);
            index++;
            test[index]=sumCol(i);
            index++;
        }   
        test[index]=sumMainDiag();
        index++;
        test[index]=sumOtherDiag();
        int flag=test[0];
        for(int i=0;i<=index;i++){
            if(test[i]!=flag){
                return false;
            }
        }
        return true;
    }

    //--------------------------------------
    //read info into the square from the input stream associated with the 
    //Scanner parameter
    //--------------------------------------
    public void readSquare(Scanner scan)
    {
        for(int i=0;i<square.length;i++){
            for(int j=0;j<square.length;j++){
                square[i][j]=scan.nextInt();
            }
        }
    }

    //--------------------------------------
    //print the contents of the square, neatly formatted
    //--------------------------------------
    public void printSquare()
    {
        for(int i=0;i<square.length;i++){
            for(int j=0;j<square.length;j++){
                System.out.print(square[i][j]+" ");
            }
            System.out.println();
        }
    }
}

SquareTest
import java.util.Scanner;
import java.io.*;

public class SquareTest
{
    public static void main(String[] args) throws IOException
    {
        Scanner scan = new Scanner(new File("C:/Users/15011/Desktop/CSA/In_Class/Array/magicData.txt"));
        int count = 1;
    	int size = scan.nextInt();
	while (size != -1){
            Square sq1=new Square(size);
            sq1.readSquare(scan);
            System.out.println("\n******** Square " + count + " ********");
	    sq1.printSquare();
            for(int i=0;i<size;i++){
                System.out.println("rows "+(i+1)+": "+sq1.sumRow(i));
            }
            for(int i=0;i<size;i++){       
                System.out.println("columns "+(i+1)+": "+sq1.sumCol(i));
            }
            System.out.println("main diagonal: "+sq1.sumMainDiag());
            System.out.println("other diagonal: "+sq1.sumOtherDiag());
            System.out.println(sq1.magic()?"It is a magic square":"It isn't a magic square.");
            size = scan.nextInt();
            count++;
	}
   }
}

本性善良的人都晚熟, 并且是被劣人催熟的, 后来虽然开窍了, 但他仍然善良与赤诚, 不断寻找同类, 最后变成最孤独的一个人。

为什么不断寻找同类,最后却只剩下孤独? 因为很多人在寻找的过程中, 把善良的本性弄丢了。 因为在这个俗世, 善良的代价就是不断被伤害, 而最后所有的刀枪不入, 都是因为学会的用伪装和圆滑去自我保护,

所以,在一个功利主义至上的社会里, 一个人想要一直保持单纯的善良, 真的是很难很难, 只有先回归公平,才可能回归善良!

可以参考一下,虽然我没加注释吧。。。。 凑活一下。。。 LAB Requirement req

The Name Class


public class Name{
    String first,middle,last;
    public Name(String f, String m, String l){
        first=f;
        middle=m;
        last=l;
    }
    public String getFirst(){
        return first;
    }
    public String getMiddle(){
        return middle;
    }
    public String getLast(){
        return last;
    }
    public String firstMiddleLast(){
        return first+" "+middle+" "+last;
    }
    public String lastFirstMiddle(){
        return last+", "+first+" "+middle;
    }
    public boolean equals(Name o){
        if(first.equalsIgnoreCase(o.getFirst())&&middle.equalsIgnoreCase(o.getMiddle())&&last.equalsIgnoreCase(o.getLast())){
            return true;
        }
        else{
            return false;
        }
    }
    public String initials(){
        return first.substring(0,1).toUpperCase()+middle.substring(0,1).toUpperCase()+last.substring(0,1).toUpperCase();
    }
    public int length(){
        return first.length()+middle.length()+last.length();
    }
}

The TestName Class


import java.util.*;
public class TestName{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        System.out.println("Enter the name of the first person. Format: firstname middlename lastname");
        Name person1=new Name(scan.next(),scan.next(),scan.next());
        System.out.println("Enter the name of the second person. Format: firstname middlename lastname");
        Name person2=new Name(scan.next(),scan.next(),scan.next());
        System.out.println(person1.firstMiddleLast());
        System.out.println(person1.lastFirstMiddle());
        System.out.println(person1.initials());
        System.out.println(person1.length());
        System.out.println(person2.firstMiddleLast());
        System.out.println(person2.lastFirstMiddle());
        System.out.println(person2.initials());
        System.out.println(person2.length());
        if(person1.equals(person2)==true){
            System.out.println("They have the same name.");
        }
        else{
            System.out.println("They don't have the same name");
        }
    }
}

一个还不错的自己写的tex 模板



\documentclass[12pt]{article}
\title{AP Micro \& Macro Economics Homework  3}
\author{Link Li\pgfornament[width=0.7cm]{94}}
\date{October 21, 2021}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{geometry}
\usepackage{qrcode}
\usepackage{pgfornament}
\usepackage{eso-pic}
\usepackage{tikzrput}
\usepackage{fontspec}
%\usepackage{boondox-cal}
%\usepackage{amsmath}

%\setmainfont{LinLibertine_R.otf}[BoldFont=LinLibertine_RZ.otf,ItalicFont=LinLibertine_RI.otf,BoldItalicFont=LinLibertine_RZI.otf,]
%\setsansfont{LinBiolinum_R.otf}[BoldFont=LinBiolinum_RB.otf,ItalicFont=LinBiolinum_RI.otf,BoldItalicFont=LinBiolinum_RBO.otf]
%\setmonofont{LinLibertine_M.otf}[BoldFont=LinLibertine_MB.otf,ItalicFont=LinLibertine_MO.otf,BoldItalicFont=LinLibertine_MBO.otf]

\setmainfont{Garamond}



\usetikzlibrary{positioning, arrows.meta, chains, scopes, calc}
\newcommand\AtPageUpperRight[1]{\AtPageUpperLeft{%
 \put(\LenToUnit{\paperwidth},\LenToUnit{0\paperheight}){#1}%
 }}%
\newcommand\AtPageLowerRight[1]{\AtPageLowerLeft{%
 \put(\LenToUnit{\paperwidth},\LenToUnit{0\paperheight}){#1}%
 }}%
\AddToShipoutPictureBG{%
   \AtPageUpperLeft{\put(0,-25){\pgfornament[width=1.75cm]{37}}}
   \AtPageUpperRight{\put(-50,-25){\pgfornament[width=1.75cm,symmetry=v]{37}}}
   \AtPageLowerLeft{\put(0,25){\pgfornament[width=1.75cm,symmetry=h]{37}}}
   \AtPageLowerRight{\put(-50,25){\pgfornament[width=1.75cm,symmetry=c]{37}}}
}

\begin{document}
\maketitle

\section{}

\subsection{i.}
By definition and graphing, we could fathom out that the producer pays the whole tax. Economically intuitively speaking, the more inelastic one side is, the more tax one side will settle. Like if you and your friends go out to have dinner. Only one person is going to pay the bill. There is no doubt that the person who least cares about price will pay the bill. (If they do not know AA)

\subsection{ii.}

No DWL. Graphically, when the supply curve becomes more and more perfectly inelastic, the area of DWL gets closer and closer to zero. Economically intuitively speaking, there is no "can happen but not happen" things. Hence there is no DWL.

\subsection{iii.}
Interest-based products. For instance, I am a sculpture fanatic, and I spend my whole spare time making sculptures. I don't want to keep my works, and then I sell them. But I never care how much my sculpture can sell. I just love making them. 
\subsection{iv.}
The producer. Because producers are less sensitive(more inelastic) of price. 
\subsection{v.}
It has DWL. The amount of DWL is the triangle.(Sorry the graph is on the next page......)
\begin{figure}[ht]
   \centering
   \includegraphics[scale=0.6]{1.png}
   \end{figure}   
\subsection{vi.}
1. The price of one kind of necessity in local market. 2. President's political preference(But the independent variable is the difference president).


\section{}

\subsection{i.}
$$elasticity=\frac{\frac{\Delta Q}{Q}}{\frac{\Delta P}{P}}=\frac{\%\Delta Q}{\%\Delta P}=\frac{30\%}{20\%}=1.5$$
e>1
\\elastic
\subsection{ii.}
$$elasticity=\frac{\frac{1200-1000}{\frac{1200+1000}{2}}}{\frac{2.4-2}{\frac{2.4+2}{2}}}=1$$
unit elastic
\subsection{iii.}
$$elasticity=\frac{\frac{\Delta Qa}{Qa}}{\frac{\Delta Pb}{Pb}}=\frac{\%\Delta Qa}{\%\Delta Pb}=\frac{25\%}{50\%}=0.5$$
e>0\\
substitute
\subsection{iv.}
$$elasticity=\frac{\%\Delta Q}{\%\Delta Income}=\frac{\frac{1800-2000}{\frac{2000+1800}{2}}}{20\%}=-0.526$$
e<0\\
inferior

\subsection{v.}
$$elasticity=\frac{\frac{300000-220000}{\frac{300000+220000}{2}}}{\frac{3-2}{\frac{3+2}{2}}}=0.769$$
e<1\\
inelastic
\subsection{vi.}
Increase.
Because inelastic indicates the $\% \Delta Q< \% \Delta P.$ Then after the price increase, the total revenue will increase because it equals=P*Q.


\section{}
Absolutely not. That lose doesn't brought by trade. Trade only exist when that trade is reciprocal. We can't says the trade deficit is "lose". Besides, if a country issue a lot of currency in to make their money devalued in order to have a higher export. We can't say they "win" money. Likewise, we can't just care about the numbers in trade without consider anything else.

\section{}


\subsection{i.}
No comparative advantages.\\
Import.\\
(Simply thinking)
\subsection{ii.}
From surplus' perspective, the consumer will win. The gain is larger. Because the increased consumer surplus is larger than the decreased producer surplus. Graphically, the increased consumer surplus: b+c, is larger than the decreased producer surplus: b.
\begin{figure}[h]
   \centering
   \includegraphics[scale=0.6]{im.png}
   \end{figure}  
\subsection{iii.}
The cosumer will still win. But the society(or the market) will relatively lose(compare to the situation without tariff). And the gov also win(if they just care about revenue).


\subsection{iv.}
see
\begin{figure}[h]
   \centering
   \includegraphics[scale=0.6]{imm.png}
   \end{figure} 


\end{document}

mignon为什么画的如此之好? haha Source: https://www.pixiv.net/en/artworks/91206125 By Pixiv User : Mignon

今天忽然到洛谷上看到自己三年前,还没有退役的时候写的代码 感慨万千 初二初三高一的不学习沉迷lol上课睡觉打游戏从来没写过作业导致了现在废物的我 一个快排模板


#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5;
int s[N];
int tmp[N];
int tot=0;
void same(int left,int mid,int right){
	int i=left;
	int j=mid+1;
	int tot=left;
	while(i<=mid||j<=right){
		if(i>mid) tmp[tot++]=s[j++];
		else if(j>right){
			tmp[tot++]=s[i++];
		}
		else {
			if(s[i]>s[j]){
				tmp[tot++]=s[j++];
			}
			else{
				tmp[tot++]=s[i++];
			}
		}
	}
	for(int k=left;k<=right;k++)
		s[k]=tmp[k];
}
void msort(int left,int right){
	if(left==right) return ;
	int mid=(left+right)/2;
	msort(left,mid);
	msort(mid+1,right);
	same(left,mid,right);
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i];
	}
	
	msort(1,n);
	for(int i=1;i<=n;i++){
		cout<<s[i]<<" ";
	}
	cout<<endl;
	return 0;
}