GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Algorithm/quick_sort&matrix scaling at master · TinyorkZheng/Algorithm

Expand file tree

/

quick_sort&matrix scaling

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
50 lines (44 loc) · 791 Bytes
/

quick_sort&matrix scaling

Copy path

File metadata and controls

50 lines (44 loc) · 791 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<iostream>
using namespace std;
struct mat{
int mm[3][3];
};
mat e_e(mat a,mat e,int n,int A,int B)
{
mat c;
for(int i=0;i<n;++i)
for(int j=0;j<n;++j)
{
c.mm[i][j]=0;
for(int k=0;k<n;++k)
{
c.mm[i][j]=c.mm[i][j]+a.mm[i][k]*e.mm[k][j];
if(c.mm[i][j]>6) c.mm[i][j]=c.mm[i][j]%7;
}
}
return c;
}
int e_fun_e(int A,int B,int q)
{
mat a,e;
a.mm[0][1]=a.mm[1][0]=0;
a.mm[1][1]=a.mm[0][0]=1;
e.mm[0][0]=A;e.mm[0][1]=B;
e.mm[1][0]=1;e.mm[1][1]=0;
while(q){
if(q&1) a=e_e(a,e,2,A,B);
e=e_e(e,e,2,A,B);
q>>=1;
}
return (a.mm[0][0]+a.mm[0][1])%7;
}
// f[0] = 0 ; f[1] = 1 ; f[2] = 2 ; f[3] = 3 ;
int main()
{
int a,b,n;
while(cin>>a>>b>>n&&a!=0){
if(n==1||n==2) cout<<1<<endl;
else cout<<e_fun_e(a,b,n-2)<<endl;
}
return 0;
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.